⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 omniobjref.cc

📁 编译工具
💻 CC
📖 第 1 页 / 共 3 页
字号:
// -*- Mode: C++; -*-//                            Package   : omniORB// omniObjRef.cc              Created on: 26/2/99//                            Author    : David Riddoch (djr)////    Copyright (C) 1996-1999 AT&T Research Cambridge////    This file is part of the omniORB library////    The omniORB library is free software; you can redistribute it and/or//    modify it under the terms of the GNU Library General Public//    License as published by the Free Software Foundation; either//    version 2 of the License, or (at your option) any later version.////    This library is distributed in the hope that it will be useful,//    but WITHOUT ANY WARRANTY; without even the implied warranty of//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU//    Library General Public License for more details.////    You should have received a copy of the GNU Library General Public//    License along with this library; if not, write to the Free//    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA//    02111-1307, USA////// Description:///*  $Log: omniObjRef.cc,v $  Revision 1.2.2.29  2003/02/03 16:53:15  dgrisby  Force type in constructor argument to help confused compilers.  Revision 1.2.2.28  2002/10/14 20:07:13  dgrisby  Per objref / per thread timeouts.  Revision 1.2.2.27  2002/01/02 18:17:41  dpg1  Segfault during final clean-up if ORB not initialised.  Revision 1.2.2.26  2001/11/12 13:46:08  dpg1  _unchecked_narrow, improved _narrow.  Revision 1.2.2.25  2001/11/08 16:33:52  dpg1  Local servant POA shortcut policy.  Revision 1.2.2.24  2001/10/17 16:33:28  dpg1  New downcast mechanism for cdrStreams.  Revision 1.2.2.23  2001/09/19 17:26:51  dpg1  Full clean-up after orb->destroy().  Revision 1.2.2.22  2001/09/03 16:53:23  sll  In _invoke and _locateRequest, set the deadline from orbParameters into the  calldescriptor.  Revision 1.2.2.21  2001/08/21 11:02:17  sll  orbOptions handlers are now told where an option comes from. This  is necessary to process DefaultInitRef and InitRef correctly.  Revision 1.2.2.20  2001/08/17 17:12:40  sll  Modularise ORB configuration parameters.  Revision 1.2.2.19  2001/08/15 17:59:11  dpg1  Minor POA bugs.  Revision 1.2.2.18  2001/08/15 10:26:13  dpg1  New object table behaviour, correct POA semantics.  Revision 1.2.2.17  2001/08/03 17:41:23  sll  System exception minor code overhaul. When a system exeception is raised,  a meaning minor code is provided.  Revision 1.2.2.16  2001/07/31 16:10:37  sll  Added GIOP BiDir support.  Revision 1.2.2.15  2001/06/08 17:12:22  dpg1  Merge all the bug fixes from omni3_develop.  Revision 1.2.2.14  2001/05/31 16:18:14  dpg1  inline string matching functions, re-ordered string matching in  _ptrToInterface/_ptrToObjRef  Revision 1.2.2.13  2001/05/29 17:03:52  dpg1  In process identity.  Revision 1.2.2.12  2001/05/11 14:26:29  sll  Use OMNIORB_THROW in rethrows to get better tracing info.  Revision 1.2.2.11  2001/05/10 15:08:38  dpg1  _compatibleServant() replaced with _localServantTarget().  createIdentity() now takes a target string.  djr's fix to deactivateObject().  Revision 1.2.2.10  2001/05/09 17:04:24  sll  _realNarrow() now propagates location forward flag when it has to create  a new object reference.  Revision 1.2.2.9  2001/05/02 16:11:44  sll   _realNarrow() calls createObjRef with the right locking and arguments.  Revision 1.2.2.8  2001/04/18 18:18:06  sll  Big checkin with the brand new internal APIs.  Revision 1.2.2.7  2000/12/05 17:39:31  dpg1  New cdrStream functions to marshal and unmarshal raw strings.  Revision 1.2.2.6  2000/11/07 18:44:03  sll  Renamed omniObjRef::_hash and _is_equivalent to __hash and __is_equivalent  to avoid name clash with the member functions of CORBA::Object.  Revision 1.2.2.5  2000/11/03 19:12:07  sll  Use new marshalling functions for byte, octet and char. Use get_octet_array  instead of get_char_array and put_octet_array instead of put_char_array.  Revision 1.2.2.4  2000/10/06 16:37:48  sll  _invoke() can now cope with a call descriptor with no local call function.  Revision 1.2.2.3  2000/10/03 17:37:08  sll  Changed omniIOR synchronisation mutex from omni::internalLock to its own  mutex.  Revision 1.2.2.2  2000/09/27 18:40:38  sll  Removed obsoluted _getRopeAndKey()  New members _getIOR(), _marshal(), _unMarshal(), _toString,  _fromString(),  _hash(), _is_equivalent().  Revision 1.2.2.1  2000/07/17 10:35:56  sll  Merged from omni3_develop the diff between omni3_0_0_pre3 and omni3_0_0.  Revision 1.3  2000/07/13 15:25:56  dpg1  Merge from omni3_develop for 3.0 release.  Revision 1.1.2.6  2000/06/22 10:40:16  dpg1  exception.h renamed to exceptiondefs.h to avoid name clash on some  platforms.  Revision 1.1.2.5  2000/03/01 17:57:41  dpg1  New omniObjRef::_compatibleServant() function to support object  references and servants written for languages other than C++.  Revision 1.1.2.4  1999/11/08 09:45:17  djr  Fixed bug in omniObjRef::_real_is_a().  Revision 1.1.2.3  1999/10/27 17:32:14  djr  omni::internalLock and objref_rc_lock are now pointers.  Revision 1.1.2.2  1999/10/14 16:22:14  djr  Implemented logging when system exceptions are thrown.  Revision 1.1.2.1  1999/09/22 14:26:59  djr  Major rewrite of orbcore to support POA.*/#include <omniORB4/CORBA.h>#include <omniORB4/minorCode.h>#include <omniORB4/callDescriptor.h>#include <objectTable.h>#include <objectAdapter.h>#include <excepthandler.h>#include <exceptiondefs.h>#include <objectStub.h>#include <giopStrand.h>#include <giopStream.h>#include <omniCurrent.h>#include <poaimpl.h>#include <initialiser.h>#include <orbOptions.h>#include <orbParameters.h>#include <shutdownIdentity.h>OMNI_USING_NAMESPACE(omni)static omniObjRef* objref_list = 0;// Linked list of all non-nil object references.//  Protected by <omni::objref_rc_lock>.//////////////////////////////////////////////////////////////////////////////             Configuration options                                      //////////////////////////////////////////////////////////////////////////////CORBA::Boolean orbParameters::verifyObjectExistsAndType = 1;//  If the value of this variable is 0 then the ORB will not//  send a GIOP LOCATE_REQUEST message to verify the existence of//  the object prior to the first invocation. Setting this variable//  if the other end is a buggy ORB that cannot handle GIOP//  LOCATE_REQUEST. ////  Valid values = 0 or 1////////////////////////////////////////////////////////////////////////////const char*omniObjRef::_localServantTarget(){  return pd_intfRepoId;}CORBA::BooleanomniObjRef::_real_is_a(const char* repoId){  if( !repoId )  return 0;  if( _ptrToObjRef(repoId) )                             return 1;  if( omni::ptrStrMatch(repoId, pd_mostDerivedRepoId) )  return 1;  // Reach here because pd_flags.type_verified == 0, and we could not  // verify the inheritance relationship using compile-time information.  // Thus we ask our implementation if it is an instance of the given  // type.  return _remote_is_a(repoId);}void*omniObjRef::_realNarrow(const char* repoId){  ASSERT_OMNI_TRACEDMUTEX_HELD(*omni::internalLock, 0);  OMNIORB_ASSERT(repoId && *repoId);  // Attempt to narrow the reference using static type info.  void* target = _ptrToObjRef(repoId);  if( target ) {    omni::internalLock->lock();    omniLocalIdentity* lid = omniLocalIdentity::downcast(_identity());    if (!lid ||	(lid && !lid->deactivated() && lid->servant() &&	 lid->servant()->_ptrToInterface(repoId))) {      // This object reference can be used directly.      omni::internalLock->unlock();      omni::duplicateObjRef(this);    }    else {      // The interface type is OK, but we can't use this objref.      // Create a new objref based on the IOR      omni::internalLock->unlock();      omniObjRef* objref;      omniIOR*    ior;      {	omni_tracedmutex_lock sync(*omniIOR::lock);	ior = pd_ior->duplicateNoLock();      }      {	omni_tracedmutex_lock sync(*omni::internalLock);	objref = omni::createObjRef(repoId,ior,1,0);	objref->pd_flags.forward_location = pd_flags.forward_location;	objref->pd_flags.type_verified = 1;	objref->pd_flags.object_exists = 1;      }      if( objref ) {	target = objref->_ptrToObjRef(repoId);	OMNIORB_ASSERT(target);      }    }  }  else {    // Either:    //  1. This proxy object was created for an object type for which we    //     do not have an authoritative answer to its inheritance relation.    //  2. The object's actual most derived type has been changed to a    //     more derived type after this object reference is generated.    //     Since the type ID in the IOR is only considered as a hint,    //     we cannot give up without asking the object about it.    // Use _is_a() to query the object to find out if <repoId> is the    // interface repo id of a base type of this object.    if( _real_is_a(repoId) ) {      // OK, the actual object does support the interface <repoId>.      // However <repoId> is not necassarily a base type of our      // most derived id -- since the implementation may have been      // replaced by one of a more derived type.  In this case the      // narrow will fail, since we can't be expected to know this.      omniObjRef* objref;      omniIOR* ior;      {	omni_tracedmutex_lock sync(*omniIOR::lock);	ior = pd_ior->duplicateNoLock();      }      {	omni_tracedmutex_lock sync(*omni::internalLock);	objref = omni::createObjRef(repoId,ior,1,_identity());	objref->pd_flags.forward_location = pd_flags.forward_location;	objref->pd_flags.type_verified = 1;	objref->pd_flags.object_exists = 1;      }      if( objref ) {	target = objref->_ptrToObjRef(repoId);	OMNIORB_ASSERT(target);      }    }  }  return target;}void*omniObjRef::_uncheckedNarrow(const char* repoId){  ASSERT_OMNI_TRACEDMUTEX_HELD(*omni::internalLock, 0);  OMNIORB_ASSERT(repoId && *repoId);  // Attempt to narrow the reference using static type info.  void* target = _ptrToObjRef(repoId);  if( target ) {    omni::internalLock->lock();    omniLocalIdentity* lid = omniLocalIdentity::downcast(_identity());    if (!lid ||	(lid && !lid->deactivated() && lid->servant() &&	 lid->servant()->_ptrToInterface(repoId))) {      // This object reference can be used directly.      omni::internalLock->unlock();      omni::duplicateObjRef(this);    }    else {      omni::internalLock->unlock();      target = 0;    }  }  if( !target ) {    // Create a new objref based on the IOR    omniObjRef* objref;    omniIOR*    ior;    {      omni_tracedmutex_lock sync(*omniIOR::lock);      ior = pd_ior->duplicateNoLock();    }    {      omni_tracedmutex_lock sync(*omni::internalLock);      objref = omni::createObjRef(repoId,ior,1,0);      objref->pd_flags.forward_location = pd_flags.forward_location;      objref->pd_flags.type_verified = 1;    }    target = objref->_ptrToObjRef(repoId);  }  OMNIORB_ASSERT(target);  return target;}voidomniObjRef::_assertExistsAndTypeVerified(){  ASSERT_OMNI_TRACEDMUTEX_HELD(*omni::internalLock, 0);  // NB. We don't lock here to protect <pd_flags> while reading.  This  // just means that there could potentially be multiple threads doing  // the following work simultaneously.  A waste, but not a disaster.  // We do need to lock when writing of course.  if( !pd_flags.type_verified ) {    if( !_remote_is_a(pd_intfRepoId) ) {      if( omniORB::traceLevel > 1 ) {	omniORB::logger log;	log <<	  "omniORB: The object with the IR repository ID: " <<	  pd_mostDerivedRepoId << "\n"	  " returns FALSE to the query _is_a(\"" << pd_intfRepoId << "\").\n"	  " A CORBA::INV_OBJREF is raised.\n";      }      OMNIORB_THROW(INV_OBJREF,INV_OBJREF_InterfaceMisMatch,		    CORBA::COMPLETED_NO);    }    {      omni::internalLock->lock();      pd_flags.type_verified = 1;      pd_flags.object_exists = 1;      omni::internalLock->unlock();    }    return;  }  if( !pd_flags.object_exists ) {    _locateRequest();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -