[omniORB] Getting a servant pointer given a reference
Russell Kliese
russell at eminence.com.au
Wed Apr 13 13:39:13 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.
I didn't think to go back and look at that stuff. That's all it was. The getPOA
function was just returning a poa_var. This was changed to:
return PortableServer::POA::_duplicate(poa);
And that solved the problems. The segfaults happending further down the
track was caused by a similar problem.
Thanks for the help and quick response.
Cheers,
Russell Kliese
--
<http://www.eminence.com.au/> Eminence Technology Pty Ltd
PO Box 118, Moorooka QLD 4105
Web: www.eminence.com.au <http://www.eminence.com.au/>
Ph: +61-7-3277-4100
Fax: +61-7-3277-4577
More information about the omniORB-list
mailing list