[omniORB] thread-sync issue on shutdown
henning.schmidt@philips.com
henning.schmidt@philips.com
Thu, 3 May 2001 13:16:26 -0500
Hi,
I discovered something that might be a thread-synchonization issue in o=
mniORB. I also found the workaround and don't think it's a severe probl=
em. Wanted to share it anyways. After all it may well be that I misunde=
rstood something.
I have one thread (A) that acts as the ORB's main thread. So all it bas=
ically does is the following:
// thread (A)
try { orb->run(); }
catch (CORBA::Exception e) { /* print type of exception */ }
My second thread (B) resolves a ference to some object like as in the f=
ollowing code:
// thread (B)
CORBA::Object_var genericObj =3D orb->string_to_object (someSIOR);
MyType_var myOby =3D MyType::_narrow(genericObj);
assert (!CORBA::is_nil(myObj));
/* (a) */
This runs fine so far.
Since I am still building up my code I am currently not doing anything =
with <myObj>. Instead I delete the ORB immediatley after the above line=
s.
So here are the following lines for thread (B):
// thread (B) - continuing
orb->shutdown (1);
/* (b) */
orb->destroy ();
Now here's the thing: Every once in a while (roughly one out of two tim=
es) thread (B) does not arrive at point (b). Instead thread (A) catche=
s <CORBA::BAD_INV_ORDER> in my above catch-block. But I also found a wo=
rkaround: I can avoid the exception by=20
letting thread (B) sleep for some time (e.g. 1 second) at point (a). So=
I aparently give thread (A) some time to deal with the new situation a=
fter I have generated <myObj> before I call orb->shutdown(1). If I do i=
t this way I never get the exception and=20
I can destroy my ORB successfully. So I guess there is some synchroniza=
tion issue between the two threads.
BTW: this is on a single-CPU machine (SGI O2 running omniORB3.0.2 under=
IRIX 6.5.10f).
Since this is not exactly a realistic way of using omniORB and also the=
re is a workaround I am not concearned about this at all. Just wanted t=
o share this with you and may be get some feedback if someone wants to =
bother.
;Henning
--
H. Henning Schmidt <Henning.Schmidt@Philips.com>
Thomson Multimedia Broadcast Solutions
Film Imaging Products
phone: +1 (408) 617 5751
fax: +1 (408) 617 7713
http://www.broadcast.philips.com/Web/FProductType.asp?lNodeId=3D282
=