corbaboa.cc
来自「编译工具」· CC 代码 · 共 1,378 行 · 第 1/3 页
CC
1,378 行
break; case DESTROYED: startRequest(); omni::internalLock->unlock(); OMNIORB_THROW(OBJECT_NOT_EXIST,OBJECT_NOT_EXIST_BOANotInitialised, CORBA::COMPLETED_NO); }}//////////////////////////////////////////////////////////////////////////////////////////////// omniOrbBoaServant ///////////////////////////////////////////////////////////////////////////////////////////////omniOrbBoaServant::~omniOrbBoaServant() {}omniOrbBoaServant::omniOrbBoaServant(){ omniORB::generateNewKey(pd_key);}voidomniOrbBoaServant::_dispose(){ ASSERT_OMNI_TRACEDMUTEX_HELD(*omni::internalLock, 0); ASSERT_OMNI_TRACEDMUTEX_HELD(boa_lock, 0); boa_lock.lock(); if( !the_boa ) { boa_lock.unlock(); OMNIORB_THROW(OBJ_ADAPTER,OBJ_ADAPTER_BOANotInitialised, CORBA::COMPLETED_NO); } // We have to grab a ref to the boa here, since <boa_lock> is // released during omniOrbBOA::dispose() -- thus the_boa could // be released under our feet! the_boa->incrRefCount_locked(); omniOrbBOA* boa = the_boa; CORBA::BOA_var ref_holder(boa); omni::internalLock->lock(); if (_activations().size() != 0) { OMNIORB_ASSERT(_activations().size() == 1); boa->dispose(_activations()[0]); }}voidomniOrbBoaServant::_obj_is_ready(){ boa_lock.lock(); if( !the_boa ) { boa_lock.unlock(); OMNIORB_THROW(OBJ_ADAPTER,OBJ_ADAPTER_BOANotInitialised, CORBA::COMPLETED_NO); } omniObjKey key((const CORBA::Octet*) &pd_key, sizeof(omniOrbBoaKey)); omni::internalLock->lock(); omniObjTableEntry* entry = omniObjTable::newEntry(key); if( !entry ) { omni::internalLock->unlock(); boa_lock.unlock(); OMNIORB_THROW(OBJECT_NOT_EXIST, OBJECT_NOT_EXIST_NoMatch, CORBA::COMPLETED_NO); } entry->setActive(this, the_boa); omni::internalLock->unlock(); entry->insertIntoOAObjList(the_boa->activeObjList()); boa_lock.unlock();}void*omniOrbBoaServant::_this(const char* repoId){ OMNIORB_ASSERT(repoId); omni::internalLock->lock(); omniObjRef* objref; if (_activations().size() > 0) { omniObjTableEntry* entry = _activations()[0]; objref = omni::createLocalObjRef(_mostDerivedRepoId(), repoId, entry); } else { objref = omni::createLocalObjRef(_mostDerivedRepoId(), repoId, (const CORBA::Octet*)&pd_key, sizeof(omniOrbBoaKey)); } omni::internalLock->unlock(); OMNIORB_ASSERT(objref); return objref->_ptrToObjRef(repoId);}omniObjRef*omniOrbBoaServant::_do_get_interface(){ // repoId should not be empty for statically defined // servants. We do not support dynamic BOA servants. const char* repoId = _mostDerivedRepoId(); OMNIORB_ASSERT(repoId && *repoId); // Obtain the object reference for the interface repository. CORBA::Object_var repository = CORBA::Object::_nil(); try { repository = omniInitialReferences::resolve("InterfaceRepository"); } catch (...) { } if( CORBA::is_nil(repository) ) OMNIORB_THROW(INTF_REPOS,INTF_REPOS_NotAvailable, CORBA::COMPLETED_NO); // Make a call to the interface repository. omniStdCallDesc::_cCORBA_mObject_i_cstring call_desc(omniDynamicLib::ops->lookup_id_lcfn, "lookup_id", 10, repoId); repository->_PR_getobj()->_invoke(call_desc); return call_desc.result() ? call_desc.result()->_PR_getobj() : 0;}//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////staticCORBA::BooleanisValidId(const char* id) { const char** p = boa_ids; while (*p) { if (strcmp(*p,id) == 0) return 1; p++; } return 0;}staticconst char*myBoaId() { return boa_ids[0];}staticvoidmove_args(int& argc,char **argv,int idx,int nargs){ if ((idx+nargs) <= argc) { for (int i=idx+nargs; i < argc; i++) { argv[i-nargs] = argv[i]; } argc -= nargs; }}staticCORBA::Booleanparse_BOA_args(int& argc, char** argv, const char* boa_identifier){ CORBA::Boolean boaId_match = 0; if (boa_identifier) { if (!isValidId(boa_identifier)) { if (omniORB::trace(1)) { omniORB::logger l; l << "BOA_init failed -- the BOAid (" << boa_identifier << ")" " is not " << myBoaId() << "\n"; } return 0; } if( omniORB::trace(1) && strcmp(boa_identifier, myBoaId()) ) { if( omniORB::trace(1) ) { omniORB::logger l; l << "WARNING -- using BOAid " << boa_identifier << " (should be " << myBoaId() << ")." << "\n"; } } } int idx = 1; while (argc > idx) { // -BOAxxxxxxxx ? if (strlen(argv[idx]) < 4 || !(argv[idx][0] == '-' && argv[idx][1] == 'B' && argv[idx][2] == 'O' && argv[idx][3] == 'A')) { idx++; continue; } // -BOAid <id> if (strcmp(argv[idx],"-BOAid") == 0) { if ((idx+1) >= argc) { omniORB::logs(1, "BOA_init failed: missing -BOAid parameter."); return 0; } if (!isValidId(argv[idx+1]) ) { if ( omniORB::trace(1) ) { omniORB::logger l; l << "BOA_init failed -- the BOAid (" << argv[idx+1] << ") is not " << myBoaId() << "\n"; } return 0; } if( strcmp(argv[idx + 1], myBoaId()) ) { if( omniORB::trace(1) ) { omniORB::logger l; l << "WARNING -- using BOAid " << boa_identifier << " (should be " << myBoaId() << ")." << "\n"; } } boaId_match = 1; move_args(argc,argv,idx,2); continue; } // -BOAno_bootstrap_agent if (strcmp(argv[idx],"-BOAno_bootstrap_agent") == 0) { orbParameters::supportBootstrapAgent = 0; move_args(argc,argv,idx,1); continue; } // -BOAiiop_port <port number>[,<port number>]* // -BOAiiop_name_port <hostname[:port number]> -- obsoleted options if (strcmp(argv[idx],"-BOAiiop_port") == 0 || strcmp(argv[idx],"-BOAiiop_name_port") == 0) { if (omniORB::trace(1)) { omniORB::logger log; log << "BOA_init failed: " << argv[idx] << " is now obsolete, use -ORBendpoint instead.\n"; } return 0; } // -BOAhelp if (strcmp(argv[idx],"-BOAhelp") == 0) { omniORB::logger l; l << "Valid -BOA<options> are:\n" " -BOAid omniORB4_BOA\n" " -BOAno_bootstrap_agent\n"; move_args(argc,argv,idx,1); continue; } // Reach here only if the argument in this form: -BOAxxxxx // is not recognised. if ( omniORB::trace(1) ) { omniORB::logger l; l << "BOA_init failed: unknown BOA argument (" << argv[idx] << ")\n"; } return 0; } if (!boa_identifier && !boaId_match) { omniORB::logs(1, "BOA_init failed: BOAid is not specified."); return 0; } return 1;}///////////////////////////////////////////////////////////////////////////////////////////////// omniORB::loader ////////////////////////////////////////////////////////////////////////////////////////////////void omniORB::loader::set(omniORB::loader::mapKeyToObject_t NewMapKeyToObject) { MapKeyToObjectFunction = NewMapKeyToObject;}/////////////////////////////////////////////////////////////////////////////////////////////// omniORB::objectKey ///////////////////////////////////////////////////////////////////////////////////////////////static omni_tracedmutex key_lock;static omniORB::objectKey omniORB_seed;voidomniORB::generateNewKey(omniORB::objectKey& k){ static int first_time = 1; omni_tracedmutex_lock sync(key_lock); if ( first_time ) { first_time = 0; // one-time initialisation of the seed value // initialise the seed of the objectKey generator // Guarantee that no two keys generated on the same machine are the same // ever.#ifdef HAVE_GETTIMEOFDAY // Use gettimeofday() to obtain the current time. Use this to // initialise the 32-bit field hi and med in the seed. // On unices, add the process id to med. // Initialise lo to 0. struct timeval v;#ifdef GETTIMEOFDAY_TIMEZONE gettimeofday(&v,0);#else gettimeofday(&v);#endif omniORB_seed.hi = v.tv_sec; omniORB_seed.med = (v.tv_usec << 12);#ifdef HAVE_GETPID omniORB_seed.med += getpid();#else // without the process id, there is no guarantee that the keys generated // by this process do not clash with those generated by other processes.#endif omniORB_seed.lo = 0;#elif defined(__WIN32__) // Unique number on NT // Use _ftime() to obtain the current system time. #ifndef __BCPLUSPLUS__ struct _timeb v; _ftime(&v); omniORB_seed.hi = v.time; omniORB_seed.med = v.millitm + _getpid(); omniORB_seed.lo = 0;#else struct timeb v; ftime(&v); omniORB_seed.hi = v.time; omniORB_seed.med = v.millitm + getpid(); omniORB_seed.lo = 0;#endif#elif defined(__VMS) && __VMS_VER < 70000000 // VMS systems prior to 7.0 timeb v; ftime(&v); omniORB_seed.hi = v.time; omniORB_seed.med = v.millitm + getpid(); omniORB_seed.lo = 0;#elif defined(__vxWorks__) struct timespec v; clock_gettime(CLOCK_REALTIME, &v); omniORB_seed.hi = v.tv_sec; omniORB_seed.med = (v.tv_nsec << 2); omniORB_seed.lo = 0;#endif // // Make sure that the three fields are in little-endian, byte swap // if necessary. if (omni::myByteOrder) { // big endian omniORB_seed.hi = ((((omniORB_seed.hi) & 0xff000000) >> 24) | (((omniORB_seed.hi) & 0x00ff0000) >> 8) | (((omniORB_seed.hi) & 0x0000ff00) << 8) | (((omniORB_seed.hi) & 0x000000ff) << 24)); omniORB_seed.med = ((((omniORB_seed.med) & 0xff000000) >> 24) | (((omniORB_seed.med) & 0x00ff0000) >> 8) | (((omniORB_seed.med) & 0x0000ff00) << 8) | (((omniORB_seed.med) & 0x000000ff) << 24)); } } omniORB_seed.lo++; // note: seed.lo is in native endian k = omniORB_seed; if (omni::myByteOrder) { // big endian k.lo = ((((k.lo) & 0xff000000) >> 24) | (((k.lo) & 0x00ff0000) >> 8) | (((k.lo) & 0x0000ff00) << 8) | (((k.lo) & 0x000000ff) << 24)); } return;}omniORB::objectKeyomniORB::nullkey(){ omniORB::objectKey n; n.hi = n.med = n.lo = 0; return n;}#if defined(HAS_Cplusplus_Namespace)namespace omniORB {#endif // Some compilers which support namespace cannot handle operator== // definition prefix by omniORB::. We therefore enclose the // operator definitions in namespace omniORB scoping to avoid the problem.int operator==(const omniORB::objectKey &k1,const omniORB::objectKey &k2){ return (k1.hi == k2.hi && k1.med == k2.med && k1.lo == k2.lo) ? 1 : 0;}int operator!=(const omniORB::objectKey &k1,const omniORB::objectKey &k2){ return (k1.hi != k2.hi || k1.med != k2.med || k1.lo != k2.lo) ? 1 : 0;}#if defined(HAS_Cplusplus_Namespace)}#endifomniORB::seqOctets* omniORB::keyToOctetSequence(const omniORB::objectKey &k1){ omniORB::seqOctets* result = new omniORB::seqOctets; result->length(sizeof(omniORB::objectKey)); const CORBA::Octet* p = (const CORBA::Octet*) &k1; for (unsigned int i=0; i< sizeof(omniORB::objectKey); i++) { result->operator[](i) = p[i]; } return result;}omniORB::objectKeyomniORB::octetSequenceToKey(const omniORB::seqOctets& seq){ if (seq.length() != sizeof(omniORB::objectKey)) { OMNIORB_THROW(MARSHAL,MARSHAL_SequenceIsTooLong, CORBA::COMPLETED_NO); } omniORB::objectKey result; CORBA::Octet* p = (CORBA::Octet*) &result; for (unsigned int i=0; i< sizeof(omniORB::objectKey); i++) { p[i] = seq[i]; } return result;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?