[omniORB] Multiple times ORB_init

Brecht Vermeulen brecht.vermeulen@rug.ac.be
Thu, 11 Oct 2001 10:35:23 +0200


Hi all,

Is it legal to call multiple times CORBA::ORB_init in an application
(e.g. in a Nameservice wrapper library, in a separate thread, in the
main() ) (I didn't find directly anyhing in the archives) ? (and receive
multiple references to the same ORB, so no different options are needed)

I looked in the omniORB code and found the following:

CORBA::ORB_ptr
CORBA::ORB_init(int& argc, char** argv, const char* orb_identifier,
                const char* options[][2])
{
  omni_tracedmutex_lock sync(orb_lock);
 
  if( the_orb ) {
    the_orb->_NP_incrRefCount();
    return the_orb;
  }


so, to my opinion, it is legal and it only increases the ref count in
the orb and returns a new reference (which has to be released of
course).

The code of ORB::_duplicate is similar, so I think it is okay to do
this.

CORBA::ORB_ptr
CORBA::ORB::_duplicate(CORBA::ORB_ptr obj)
{
  if( !CORBA::is_nil(obj) )  obj->_NP_incrRefCount();
 
  return obj;
}


Is this specified in the CORBA standard or is it something omniORB
specific ? (and hence is it better to use e.g. a singleton design
pattern or global variables ?)

best regards,
Brecht