Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Servant life and CORBA destroy (C++)

42 views
Skip to first unread message

corremn

unread,
Nov 24, 2011, 12:19:56 AM11/24/11
to
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

unread,
Nov 24, 2011, 4:46:18 PM11/24/11
to
On 24.11.2011 06:19, corremn wrote:
> 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

unread,
Nov 24, 2011, 7:20:43 PM11/24/11
to
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.
0 new messages