Should youtown the ORB from CORBA::ORB_init?



Hi,

I guess all of you have seen this before, when one of the orbitcpp tests
exit:

** ERROR **: file orbit-object.c: line 146 (do_unref): assertion failed: (robj->refs < ORBIT_REFCOUNT_MAX && robj->refs > 0)
aborting...
Aborted

So I thought this was going to turn out to be some hard-to-find
refcounting issue, but it looks like the cause is pretty simple.
All the example executables have something like this:

  CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "orbit-local-orb");
	
CORBA::ORB_var is a smartpointer class that unrefs the orb when it's
destroyed (in this case, when main() returns). However, it looks like
the reference that ORB_init returns isn't owned by the application -- so
you don't have to unref it. Changing the above line to

  CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv, "orbit-local-orb");

gets rid of the above crash (it's more than just a warning, if you think
about applications that want to do stuff after returning from their
CORBA-handling function).

So, the question is, which one should be the correct behaviour, according
to the CORBA specs? It would be quite easy to modify CORBA::ORB_init to
return a duplicate of the C ORB, thus the correct behaviour would be to
use a _var smartpointer to store it. The other option is to leave things
as-is and recommend the usage of _ptr to store the ORB (of course this
would also mean modifying the existing tests).

Unfortunately, I just can't find a webpage about CORBA/C++ that would
answer questions like this, so I'm counting on you guys.

Thanks in advance,
	Gergo


-- 
   .--= ULLA! =---------------------.   `We are not here to give users what
   \     http://cactus.rulez.org     \   they want'  -- RMS, at GUADEC 2001
    `---= cactus cactus rulez org =---'
A man's best friend is his dogma.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]