[omniORB] Getting a servant pointer given a reference
Clarke Brunt
clarke.brunt at trafficmaster.co.uk
Tue Apr 12 10:28:38 BST 2005
> In a nutshell, I am trying to figure out a way to get a
> pointer to the
> servent object given a reference.
>
> So far, I have tried the following:
>
> NodeProxy* NodeProxy::getNodeProxy (dom::Node_ptr node) {
>
> PortableServer::POA_var poa = server->getPOA() ;
> PortableServer::ServantBase* serv =
> poa->reference_to_servant(node);
>
> NodeProxy* nodeProxy = dynamic_cast<NodeProxy*>(serv);
> // check to make sure it's not null
> return nodeProxy;
> }
>
> With omniORB3 I get the following:
>
> omniORB: ERROR -- trying to release an object with reference
> count <= 0.
> CORBA::release() may have been called too many times on an object
> reference.
>
> I have experimented with _add_ref() to no avail.
>
> With omniORB4 I am just getting a segfault further down the track ;(
Perhaps I'm missing something, but the only bit of that code which appears
that it could possibly be wrong is the getPOA and the assignment of its
result to a POA_var. Is getPOA your own method, and does it duplicate the
POA before returning it? If it doesn't duplicate it, then the release in
POA_var's destructor would be inappropriate.
The docs say that reference_to_servant invokes _add_ref on the servant
before returning it, so a _remove_ref might be needed when you are finished
with it (possibly using ServantBase_var), but this would be the
responsibility of the caller of getNodeProxy, and doesn't appear to be
anything to do with your problem.
--
Clarke Brunt, Principal Software Engineer, Trafficmaster
More information about the omniORB-list
mailing list