Discussion:
Servant life and CORBA destroy (C++)
(too old to reply)
corremn
2011-11-24 05:19:56 UTC
Permalink
Hi,

Due to programming architecture I am in the need to init the ORB,
create a servant, incarnate the CORBA object (using _this), "do
stuff", destroy the object and call ORB->destroy.

I.e
orb = CORBA::ORB_init(...)
....
{
Test_impl vTestServant;
Test_var vObject = vTestServant._this();
}
.....
orb->destroy(); //so I can re-init the ORB in my app.

This code replicates my architecture problem. Note the '{' and '}' to
represent scoping. Here lies my problem. Once vTestServant goes out of
scope prior to orb->destroy been called, I then get a pure virtual
function call on orb->destroy(). (MSVC debug).

Is there a way to unregister servant with POA or something so this
does not happen? (something to reverse the effect of the _this()
call?) Note that this has nothing to do with activation/deactivation
of objects.

Cheers
Thomas Richter
2011-11-24 21:46:18 UTC
Permalink
Post by corremn
Hi,
Is there a way to unregister servant with POA or something so this
does not happen? (something to reverse the effect of the _this()
call?)
PortableServer::ObjectId_var oid;
PortableServer::POA_var poa;
poa = object->_default_POA();
oid = poa->servant_to_id(object);
object->_remove_ref();
poa->deactivate_object(oid);

should do. As soon as you remove the reference of the object, the POA
will notice that it can go away.

Greetings,
Thomas
corremn
2011-11-25 00:20:43 UTC
Permalink
Post by corremn
Hi,
Is there a way to unregister servant with POA or something so this
does not happen?  (something to reverse the effect of the _this()
call?)
     PortableServer::ObjectId_var oid;
     PortableServer::POA_var poa;
     poa = object->_default_POA();
     oid = poa->servant_to_id(object);
     object->_remove_ref();
     poa->deactivate_object(oid);
should do. As soon as you remove the reference of the object, the POA
will notice that it can go away.
Greetings,
        Thomas
Oh thankyou, thankyou! You can not believe how hard it was for me to
first track down the bug and then find a solution. I knew what I
wanted just could not find it.

Cheers.

Loading...