Discussion:
[omniORB] omniORB 4.1.0-rc1: servant manager ref counting missing?
Teemu Torma
2006-09-29 02:42:16 UTC
Permalink
I converted some code using servant activator to use new simple classes
instead of activated servants.

However I don't see them being destroyed after releasing the caller's
copy. Trying to follow how this is supposed to happen, I ended into
dummy _add_ref/_remove_ref methods in servant manager.

By overriding them and doing the ref counting in my servant activator
everything worked just fine and it was destroyed at the end. However,
right now this is mandatory if you want them destroyed.

Is this just a bug or missing code, or am I missing something obvious?

Teemu
Duncan Grisby
2006-09-29 22:56:05 UTC
Permalink
Post by Teemu Torma
I converted some code using servant activator to use new simple classes
instead of activated servants.
However I don't see them being destroyed after releasing the caller's
copy. Trying to follow how this is supposed to happen, I ended into
dummy _add_ref/_remove_ref methods in servant manager.
By overriding them and doing the ref counting in my servant activator
everything worked just fine and it was destroyed at the end. However,
right now this is mandatory if you want them destroyed.
Is this just a bug or missing code, or am I missing something obvious?
You're missing something, but it's not obvious... ServantManagers are
LocalObjects, and the C++ mapping version 1.1 says in section 1.35 about
LocalObject:

_add_ref

The _add_ref member function is called when the reference is
duplicated. A default implementation is provided that does nothing. A
derived implementation may use this operation to maintain a reference
count.

_remove_ref

The _remove_ref member function is called when the reference is
released. A default implementation is provided that does nothing. A
derived implementation may use this operation to maintain a reference
count, and delete the object when the count becomes zero.


So local objects are not reference counted by default. I think that's a
bizarre and inconvenient thing to require, especially since the 1.1
mapping moved the reference counting for servants into ServantBase (out
of RefCountServantBase), but that's the way it is.

If you want reference counting in your servant managers, you have to
implement it yourself.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Loading...