[omniORB] passing object references
Haarek Ryeng
Haarek.Ryeng@datarespons.no
Thu, 13 Apr 2000 06:07:44 +0200
Hello fellow OmniORBers!
Obtaining and passing references is an ever-returning
problem in distributed systems! Forgive me for sharing my
thoughts with you, as the solution might be obvious.
Background:
---------------
In my current project were not allowed to rely on a
centralised name server, thus all the CPUs in the system
implements a mini-name-to-ref-look-up-server (Obtaining
the ref. to these are another story). Servants are supposed
to answer GetRef() calls and returning their reference.
Unlike the COS name server, our name servers obtain
references from true Servants. If we mess up the reference
counting, were lead in to nasty memory leaks the next time
the Servant gets disposed.
Problem:
-----------
How to implement a A_ptr GetRef();? Do the stubs or any
other part of the Orb perform any magic to the reference
count when marshalling refs to remote clients?
Implement as in 1 and/or 2, or a totally different way? Any
of you done any similar things?
--------------------------------
OmniORBxxx:
1)
As implementation does not inherit from the _sk_A, but is
derefferd through the _tie_A template instance. A keeps a
member reference to it self:
_tie_A<>* A::_pInt = new _tie_A<>(this);
A_ptr GetRef()
{
return _pInt; // doesnt influence the ref count!
}
---------------------------
OmniORB280 and OmniORB3:
2)
A_ptr GetRef()
{
A_var ref = _pInt->_duplicate(_pInt);
ref->_retn();
return _pInt; // dummy return for the compiler;
}
CORBA 2.2 spec, and OmniORB280 and OmniORB3 impl:
A_ptr _retn() {
// yield ownership of managed object reference
A_ptr val = ptr_;
ptr_ = A::_nil();
return val;
OmniORB 2.7.1 impl:
template <class T, class T_Helper>
class _CORBA_ObjRef_Var {
.
inline T_ptr _retn(); // empty impl!
..
For those of you who is still with me:
The CORBA C++ mapping states the following for passing refs:
.The caller is responsible for the release of all out and
return object references. Release of all object references
embedded in other structures is
performed automatically by the structures themselves.
It doesnt say that the callee is supposed to do anything,
so I guess both solution 1 and 2 are correct!
The Servant only cares about its internal ref count.
- Haarek
[demime 0.97b removed an attachment of type text/x-vcard which had a name of haarek.ryeng.vcf]