[omniORB] Bug when an object implementation calls itsef from a separate thr ead

Yann.Pochon at ch.delarue.com Yann.Pochon at ch.delarue.com
Fri Sep 3 17:33:21 BST 2004


A follow-up to my previous post.

The exception from localIdentity.cc:184 is thrown because my "separate
thread" isn't an omni_thread.

So as to make the life of the application easier (no need to check if a call
on an object implementation is done from 
an omni_thread), I propose to patch the method
omniLocalIdentity::dispatch(omniCallDescriptor& call_desc) as follow:
If the calling thread isn't an omni_thread, a dummy omni_thread is created
before calling pd_adapter->dispatch() and
released just after.

See the code below:


void
omniLocalIdentity::dispatch(omniCallDescriptor& call_desc)
{
  ASSERT_OMNI_TRACEDMUTEX_HELD(*omni::internalLock, 1);
  OMNIORB_ASSERT(pd_adapter && pd_servant);

  if (pd_deactivated || !call_desc.haslocalCallFn()) {
    // This localIdentity is dead and unusable, or the call descriptor
    // is unable to do a direct local call (because it's a DII call).
    // Either way, replace the object reference's identity with an
    // inProcessIdentity and invoke on that.
    //
    // Note that in the case of a DII call, we have dropped the
    // localIdentity, meaning the next non-DII call will have to
    // re-discover it. We do it this way since if the application has
    // done one DII call, it's likely to do more, so it's best to
    // avoid repeatedly creating inProcessIdentities.

    if (omniORB::trace(15)) {
      omniORB::logger l;
      l << this << " is no longer active. Using in process identity.\n";
    }
    omniIdentity* id = omni::createInProcessIdentity(key(), keysize());
    call_desc.objref()->_setIdentity(id);
    id->dispatch(call_desc);
    return;
  }

  call_desc.localId(this);

  omniLocalIdentity_RefHolder rh(this);

  omni::localInvocationCount++;

#ifndef HAS_Cplusplus_catch_exception_by_base
  // The compiler cannot catch exceptions by base class, hence
  // we cannot trap invalid exceptions going through here.
  pd_adapter->dispatch(call_desc, this);

#else
  bool dummyCreated = false;
  try { 
    if (omni_thread::self() == NULL) {
      omni_thread::create_dummy();
      dummyCreated = true;
    }

    pd_adapter->dispatch(call_desc, this); 
    
    if (dummyCreated) 
      omni_thread::release_dummy();
  }

  catch(CORBA::Exception&) {
    if (dummyCreated) 
      omni_thread::release_dummy();
    throw;
  }
  catch(omniORB::LOCATION_FORWARD&) {
    if (dummyCreated) 
      omni_thread::release_dummy();
    throw;
  }

  catch(...) {
    if (dummyCreated) 
      omni_thread::release_dummy();
    if( omniORB::trace(2) ) {
      omniORB::logger l;
      l << "WARNING -- method \'" << call_desc.op() << "\' raised an
unknown\n"
	" exception (not a legal CORBA exception).\n";
    }
    OMNIORB_THROW(UNKNOWN,UNKNOWN_UserException, CORBA::COMPLETED_MAYBE);
  }
#endif
}


**********************************************************************
This message is strictly private and contains confidential information intended only for the use of the person named above. If you have received this e-mail in error and are not the intended recipient you must not disclose, copy or distribute it to anyone else. Please immediately advise the sender and delete this email and all attachments.

**********************************************************************




More information about the omniORB-list mailing list