corbaboa.cc
来自「编译工具」· CC 代码 · 共 1,378 行 · 第 1/3 页
CC
1,378 行
OMNIORB_ASSERT(the_boa == this); boa = the_boa; the_boa = 0; // Grab the list of active objects. if( pd_activeObjList ) pd_activeObjList->reRootOAObjList(&obj_list); boa_lock.unlock(); } // This can go outside of the <boa_lock> critical section, // since once we are in the DESTROYED state, we will never // return to the active state. if( do_inactive ) { try { adapterInactive(); } catch(...) {} } // Remove all my objects from the object table. omni::internalLock->lock(); omniObjTableEntry* entry = obj_list; while( entry ) { while (entry->state() == omniObjTableEntry::ACTIVATING) entry->wait(omniObjTableEntry::ACTIVE | omniObjTableEntry::DEACTIVATING | omniObjTableEntry::ETHEREALISING); if (entry->state() == omniObjTableEntry::ACTIVE) entry->setDeactivatingOA(); entry = entry->nextInOAObjList(); } // We need to kick anyone stuck in synchronise_request(), // or impl_is_ready(). pd_state_signal->broadcast(); // Wait until outstanding invocations have completed. waitForAllRequestsToComplete(1); entry = obj_list; while( entry ) { if (entry->state() & omniObjTableEntry::DEACTIVATING) entry->setEtherealising(); OMNIORB_ASSERT(entry->is_idle()); entry = entry->nextInOAObjList(); } // Kill the identities, but not the servants themselves. // (See user's guide 5.4). entry = obj_list; while( entry ) { OMNIORB_ASSERT(entry->is_idle()); omniObjTableEntry* next = entry->nextInOAObjList(); entry->setDead(); entry = next; } omni::internalLock->unlock(); // Wait for objects which have been detached to complete // their etherealisations. wait_for_detached_objects(); adapterDestroyed(); CORBA::release(boa);}void omniOrbBOA::obj_is_ready(omniOrbBoaServant* servant, CORBA::ImplementationDef_ptr /* ignored */){ CHECK_NOT_NIL_OR_DESTROYED(); if( !servant ) OMNIORB_THROW(BAD_PARAM,BAD_PARAM_InvalidServant, CORBA::COMPLETED_NO); servant->_obj_is_ready();}void omniOrbBOA::obj_is_ready(CORBA::Object_ptr, CORBA::ImplementationDef_ptr){ CHECK_NOT_NIL_OR_DESTROYED(); omniORB::logs(1, "CORBA::BOA::obj_is_ready() is not supported. Use\n" " _obj_is_ready(boa) on the object implementation instead."); OMNIORB_THROW(NO_IMPLEMENT, NO_IMPLEMENT_Unsupported, CORBA::COMPLETED_NO);}voidomniOrbBOA::dispose(CORBA::Object_ptr obj){ if( _NP_is_nil() ) _CORBA_invoked_nil_pseudo_ref(); if( !obj || obj->_NP_is_nil() ) return; if( obj->_NP_is_pseudo() ) OMNIORB_THROW(BAD_PARAM,BAD_PARAM_IsPseudoObject, CORBA::COMPLETED_NO); boa_lock.lock(); omni::internalLock->lock(); dispose(obj->_PR_getobj()->_identity()); // The locks will have been released on return.}CORBA::Object_ptromniOrbBOA::create(const CORBA::ReferenceData& ref, CORBA::_objref_InterfaceDef* intf, CORBA::ImplementationDef_ptr impl){ OMNIORB_THROW(NO_IMPLEMENT, NO_IMPLEMENT_Unsupported, CORBA::COMPLETED_NO); return 0;}CORBA::ReferenceData*omniOrbBOA::get_id(CORBA::Object_ptr obj){ OMNIORB_THROW(NO_IMPLEMENT, NO_IMPLEMENT_Unsupported, CORBA::COMPLETED_NO); return 0;}voidomniOrbBOA::change_implementation(CORBA::Object_ptr obj, CORBA::ImplementationDef_ptr impl){ OMNIORB_THROW(NO_IMPLEMENT, NO_IMPLEMENT_Unsupported, CORBA::COMPLETED_NO); return;}CORBA::Principal_ptromniOrbBOA::get_principal(CORBA::Object_ptr obj, CORBA::Environment_ptr env){ OMNIORB_THROW(NO_IMPLEMENT, NO_IMPLEMENT_Unsupported, CORBA::COMPLETED_NO); return 0;}voidomniOrbBOA::deactivate_impl(CORBA::ImplementationDef_ptr impl){ OMNIORB_THROW(NO_IMPLEMENT, NO_IMPLEMENT_Unsupported, CORBA::COMPLETED_NO);}voidomniOrbBOA::deactivate_obj(CORBA::Object_ptr obj){ OMNIORB_THROW(NO_IMPLEMENT, NO_IMPLEMENT_Unsupported, CORBA::COMPLETED_NO);}///////////////////// CORBA::Object /////////////////////_CORBA_BooleanomniOrbBOA::_non_existent(){ if( _NP_is_nil() ) _CORBA_invoked_nil_pseudo_ref(); omni::internalLock->lock(); _CORBA_Boolean ret = pd_state == DESTROYED ? 1 : 0; omni::internalLock->unlock(); return ret;}void*omniOrbBOA::_ptrToObjRef(const char* repoId){ OMNIORB_ASSERT(repoId); if( omni::ptrStrMatch(repoId, CORBA::BOA::_PD_repoId) ) return (CORBA::BOA_ptr) this; if( omni::ptrStrMatch(repoId, CORBA::Object::_PD_repoId) ) return (CORBA::Object_ptr) this; return 0;}voidomniOrbBOA::_NP_incrRefCount(){ boa_lock.lock(); pd_refCount++; boa_lock.unlock();}voidomniOrbBOA::_NP_decrRefCount(){ boa_lock.lock(); int done = --pd_refCount > 0; boa_lock.unlock(); if( done ) return; omniORB::logs(15, "No more references to the BOA -- deleted."); delete this;}/////////////////////////////// Override omniObjAdapter ///////////////////////////////voidomniOrbBOA::incrRefCount(){ boa_lock.lock(); pd_refCount++; boa_lock.unlock();}voidomniOrbBOA::decrRefCount(){ boa_lock.lock(); int done = --pd_refCount > 0; boa_lock.unlock(); if( done ) return; omniORB::logs(15, "No more references to the BOA -- deleted."); delete this;}voidomniOrbBOA::dispatch(omniCallHandle& handle, omniLocalIdentity* id){ ASSERT_OMNI_TRACEDMUTEX_HELD(*omni::internalLock, 1); OMNIORB_ASSERT(id); OMNIORB_ASSERT(id->servant()); OMNIORB_ASSERT(id->adapter() == this); enterAdapter(); if( pd_state != ACTIVE ) synchronise_request(); startRequest(); omni::internalLock->unlock(); if( omniORB::traceInvocations ) { omniORB::logger l; l << "Dispatching remote call \'" << handle.operation_name() << "\' to: " << id << '\n'; } if( !id->servant()->_dispatch(handle) ) { if( !id->servant()->omniServant::_dispatch(handle) ) { handle.SkipRequestBody(); OMNIORB_THROW(BAD_OPERATION,BAD_OPERATION_UnRecognisedOperationName, CORBA::COMPLETED_NO); } }}voidomniOrbBOA::dispatch(omniCallHandle& handle, const CORBA::Octet* key, int keysize){ ASSERT_OMNI_TRACEDMUTEX_HELD(*omni::internalLock, 0); OMNIORB_ASSERT(key && keysize == sizeof(omniOrbBoaKey)); omniORB::loader::mapKeyToObject_t loader = MapKeyToObjectFunction; if( !loader ) OMNIORB_THROW(OBJECT_NOT_EXIST, OBJECT_NOT_EXIST_NoMatch, CORBA::COMPLETED_NO); omniOrbBoaKey k; memcpy(&k, key, sizeof(omniOrbBoaKey)); CORBA::Object_ptr obj = loader(k); if( CORBA::is_nil(obj) ) OMNIORB_THROW(OBJECT_NOT_EXIST, OBJECT_NOT_EXIST_NoMatch, CORBA::COMPLETED_NO); else throw omniORB::LOCATION_FORWARD(obj,0);}voidomniOrbBOA::dispatch(omniCallDescriptor& call_desc, omniLocalIdentity* id){ ASSERT_OMNI_TRACEDMUTEX_HELD(*omni::internalLock, 1); OMNIORB_ASSERT(id); OMNIORB_ASSERT(id->servant()); OMNIORB_ASSERT(id->adapter() == this); enterAdapter(); if( pd_state != ACTIVE ) synchronise_request(); startRequest(); omni::internalLock->unlock(); if( omniORB::traceInvocations ) { omniORB::logger l; l << "Dispatching local call \'" << call_desc.op() << "\' to " << id << '\n'; } call_desc.doLocalCall(id->servant());}intomniOrbBOA::objectExists(const _CORBA_Octet* key, int keysize){ ASSERT_OMNI_TRACEDMUTEX_HELD(*omni::internalLock, 0); OMNIORB_ASSERT(key && keysize == sizeof(omniOrbBoaKey)); omniORB::loader::mapKeyToObject_t loader = MapKeyToObjectFunction; if( !loader ) return 0; omniOrbBoaKey k; memcpy(&k, key, sizeof(omniOrbBoaKey)); CORBA::Object_ptr obj = loader(k); if( !CORBA::is_nil(obj) ) throw omniORB::LOCATION_FORWARD(obj,0); return 0;}voidomniOrbBOA::lastInvocationHasCompleted(omniLocalIdentity* id){ ASSERT_OMNI_TRACEDMUTEX_HELD(*omni::internalLock, 1); omniObjTableEntry* entry = omniObjTableEntry::downcast(id); OMNIORB_ASSERT(entry); // This function should only ever be called with a localIdentity // which is an objectTableEntry, since those are the only ones which // can be deactivated. if (entry->state() == omniObjTableEntry::DEACTIVATING_OA) { if (omniORB::trace(15)) { omniORB::logger l; l << "BOA not etherealising object " << entry <<".\n"; } omni::internalLock->unlock(); return; } if( omniORB::trace(15) ) { omniORB::logger l; l << "BOA etherealising object.\n" << " id: " << id->servant()->_mostDerivedRepoId() << "\n"; } omniServant* servant = id->servant(); entry->setEtherealising(); entry->setDead(); omni::internalLock->unlock(); delete servant; met_detached_object();}//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////omniOrbBOA*omniOrbBOA::theBOA(){ boa_lock.lock(); omniOrbBOA* boa = the_boa; if( boa ) boa->incrRefCount_locked(); boa_lock.unlock(); return boa;}voidomniOrbBOA::dispose(omniIdentity* id){ ASSERT_OMNI_TRACEDMUTEX_HELD(boa_lock, 1); ASSERT_OMNI_TRACEDMUTEX_HELD(*omni::internalLock, 1); if( pd_state == DESTROYED ) { omni::internalLock->unlock(); boa_lock.unlock(); OMNIORB_THROW(OBJECT_NOT_EXIST,OBJECT_NOT_EXIST_NoMatch, CORBA::COMPLETED_NO); } omniObjTableEntry* entry = omniObjTableEntry::downcast(id); if( !entry || entry->state() != omniObjTableEntry::ACTIVE ) { omni::internalLock->unlock(); boa_lock.unlock(); return; } entry->setDeactivating(); entry->removeFromOAObjList(); if( entry->is_idle() ) { detached_object(); boa_lock.unlock(); lastInvocationHasCompleted(entry); } else { // When outstanding requests have completed the object // will be etherealised. omni::internalLock->unlock(); detached_object(); boa_lock.unlock(); omniORB::logs(15, "Object is still busy -- etherealise later."); }}voidomniOrbBOA::synchronise_request(){ ASSERT_OMNI_TRACEDMUTEX_HELD(*omni::internalLock, 1); // Wait until the request can proceed, or discard it. // We limit the number of threads stuck here, so as to more // closely match the semantics of the old BOA -- where // clients would be stuck in a queue on the socket, waiting // to be allowed to connect. // NB. If only the BOA is used, then the old semantics are // preserved anyway. This will only apply when the BOA and // POA are used together. if( pd_nwaiting == /*??* max */ 5 ) { startRequest(); omni::internalLock->unlock(); OMNIORB_THROW(TRANSIENT,TRANSIENT_POANoResource, CORBA::COMPLETED_NO); } pd_nwaiting++; while( pd_state == IDLE ) pd_state_signal->wait(); pd_nwaiting--; switch( pd_state ) { case IDLE: // get rid of warnings! case ACTIVE:
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?