[omniORB] servant destruction and ref counting

Duncan Grisby dgrisby@uk.research.att.com
Fri, 04 May 2001 17:18:18 +0100


On Tuesday 1 May, Stefan Seefeld wrote:

> There are indeed local references indicating an error in reference
> counting (and that is what I'm looking for). However, this shouldn't
> prevent the servant from being deleted.
> 
> Now, you didn't tell me what a reference in this context actually is.

I mean a CORBA object reference. e.g. somewhere you have a Foo_ptr
which you haven't called release() on. It may not be a problem since
it could actually be due to code along the lines of:

  {
    Foo_impl* foo_i = new Foo_impl();
    id = poa->activate_object(foo_i);
    Foo_ptr foo_obj = foo_i->_this();
    foo_i->_remove_ref();
    poa.deactivate_object(id);
  }

Here, we activate a servant, and put an object reference to it in a
_var type. The servant is deleted by the call to deactivate_object(),
but the object reference is still alive since the _var hasn't gone out
of scope yet. There's nothing wrong with this situation.

Your problem with the servant object not being deleted is probably due
to a missing Servant::_remove_ref() somewhere, and nothing to do with
the existence of local object references. To trace _add_ref() and
_remove_ref(), you can just create your own version of the
RefCountServantBase mixin which prints out debugging info. Remember to
use some concurrency control on the reference count.

Cheers,

Duncan.

-- 
 -- Duncan Grisby  \  Research Engineer  --
  -- AT&T Laboratories Cambridge          --
   -- http://www.uk.research.att.com/~dpg1 --