omniinternal.cc
来自「编译工具」· CC 代码 · 共 1,724 行 · 第 1/4 页
CC
1,724 行
// -*- Mode: C++; -*-// Package : omniORB// omniInternal.cc Created on: 25/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:// Implementation of methods defined in class omni.// /* $Log: omniInternal.cc,v $ Revision 1.2.2.41 2005/12/01 23:14:24 dgrisby Remove unsafe log message from native exception handler. Revision 1.2.2.40 2005/11/28 14:57:51 dgrisby New abortOnNativeException parameter for Windows. Revision 1.2.2.39 2005/09/19 14:23:56 dgrisby New traceFile configuration parameter. Revision 1.2.2.38 2005/04/08 00:06:14 dgrisby Remove all remaining uses of logf. Revision 1.2.2.37 2005/03/29 14:41:33 dgrisby Use omniORB logger instead of logf. May avoid a compiler / platform bug on VxWorks. Revision 1.2.2.36 2004/10/17 20:14:33 dgrisby Updated support for OpenVMS. Many thanks to Bruce Visscher. Revision 1.2.2.35 2004/07/23 13:25:44 dgrisby New traceExceptions option. Revision 1.2.2.34 2004/03/02 15:31:22 dgrisby Support for persistent server identifier. Revision 1.2.2.33 2003/08/06 20:36:49 dgrisby Shorten assertion failure message. Revision 1.2.2.32 2003/07/02 11:01:06 dgrisby Race condition in POA destruction. Revision 1.2.2.31 2003/05/28 09:59:25 dgrisby HPUX fixes broke some platforms. Revision 1.2.2.30 2003/05/22 13:41:41 dgrisby HPUX patches. Revision 1.2.2.29 2003/01/16 11:08:26 dgrisby Patches to support Digital Mars C++. Thanks Christof Meerwald. Revision 1.2.2.28 2002/09/08 21:12:39 dgrisby Properly handle IORs with no usable profiles. Revision 1.2.2.27 2002/08/16 16:03:31 dgrisby Interceptor tweaks. Revision 1.2.2.26 2002/03/27 11:44:53 dpg1 Check in interceptors things left over from last week. Revision 1.2.2.25 2002/03/18 15:13:08 dpg1 Fix bug with old-style ORBInitRef in config file; look for -ORBtraceLevel arg before anything else; update Windows registry key. Correct error message. Revision 1.2.2.24 2001/09/24 14:26:02 dpg1 Safer static translation unit counts for omnithread and final clean-up. Revision 1.2.2.23 2001/09/20 13:26:14 dpg1 Allow ORB_init() after orb->destroy(). Revision 1.2.2.22 2001/09/19 17:26:50 dpg1 Full clean-up after orb->destroy(). Revision 1.2.2.21 2001/08/21 11:02:16 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/20 13:27:43 dpg1 Correct description of objectTableSize configuration setting. Revision 1.2.2.19 2001/08/17 17:12:40 sll Modularise ORB configuration parameters. Revision 1.2.2.18 2001/08/16 14:37:07 dpg1 Fix scoping of omni::internalLock. Revision 1.2.2.17 2001/08/15 17:59:11 dpg1 Minor POA bugs. Revision 1.2.2.16 2001/08/15 10:26:13 dpg1 New object table behaviour, correct POA semantics. Revision 1.2.2.15 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.14 2001/08/01 10:08:21 dpg1 Main thread policy. Revision 1.2.2.13 2001/07/31 16:40:03 sll Added argument to selectRope. Revision 1.2.2.12 2001/07/13 15:29:59 sll Use the variable omniORB::maxServerThreadPoolSize to control invoker thread pool size. Revision 1.2.2.11 2001/05/31 16:18:13 dpg1 inline string matching functions, re-ordered string matching in _ptrToInterface/_ptrToObjRef Revision 1.2.2.10 2001/05/29 17:03:52 dpg1 In process identity. Revision 1.2.2.9 2001/05/10 15:08:37 dpg1 _compatibleServant() replaced with _localServantTarget(). createIdentity() now takes a target string. djr's fix to deactivateObject(). Revision 1.2.2.8 2001/05/09 17:05:34 sll createIdentity() now can deal with it being called more than once with the same IOR. Revision 1.2.2.7 2001/04/18 18:18:06 sll Big checkin with the brand new internal APIs. Revision 1.2.2.6 2000/11/09 12:27:57 dpg1 Huge merge from omni3_develop, plus full long long from omni3_1_develop. Revision 1.2.2.5 2000/11/03 19:14:03 sll Use _CORBA_Unbounded_Sequence_Octet instead of _CORBA_Unbounded_Sequence__Octet Revision 1.2.2.4 2000/10/09 16:22:47 sll Updated the usage of omniIOR duplicate and release to conform to the current locking requirement. 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:39:33 sll Updated to use omniIOR to store and pass the repository ID and IOP profiles of an IOR. Revision 1.1.2.16 2000/07/21 15:35:47 dpg1 Incorrectly rejected object references with incompatible target and most-derived repoIds. Revision 1.1.2.15 2000/06/27 15:40:57 sll Workaround for Cygnus gcc's inability to recognise _CORBA_Octet*& and CORBA::Octet*& are the same type. Revision 1.1.2.14 2000/06/22 10:40:16 dpg1 exception.h renamed to exceptiondefs.h to avoid name clash on some platforms. Revision 1.1.2.13 2000/04/27 10:51:13 dpg1 Interoperable Naming Service stringToObject() and objectToString() moved to uri.cc. Revision 1.1.2.12 2000/04/13 17:48:58 djr Minor improvement -- reduces times when need to verify object's type. Revision 1.1.2.11 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.10 2000/02/22 12:25:38 dpg1 A few things made `publicly' accessible so omniORBpy can get its hands on them. Revision 1.1.2.9 2000/01/27 16:31:33 djr String_member now initialised to empty string by default. Revision 1.1.2.8 2000/01/20 11:51:35 djr (Most) Pseudo objects now used omni::poRcLock for ref counting. New assertion check OMNI_USER_CHECK. Revision 1.1.2.7 1999/12/06 14:03:00 djr *** empty log message *** Revision 1.1.2.6 1999/10/29 13:18:18 djr Changes to ensure mutexes are constructed when accessed. Revision 1.1.2.5 1999/10/27 17:32:13 djr omni::internalLock and objref_rc_lock are now pointers. Revision 1.1.2.4 1999/10/14 16:22:13 djr Implemented logging when system exceptions are thrown. Revision 1.1.2.3 1999/09/27 08:48:33 djr Minor corrections to get rid of warnings. Revision 1.1.2.2 1999/09/24 15:01:35 djr Added module initialisers, and sll's new scavenger implementation. Revision 1.1.2.1 1999/09/22 14:26:57 djr Major rewrite of orbcore to support POA.*/#include <omniORB4/CORBA.h>#ifdef HAS_pch#pragma hdrstop#endif#include <omniORB4/proxyFactory.h>#include <omniORB4/omniServant.h>#include <objectTable.h>#include <inProcessIdentity.h>#include <remoteIdentity.h>#include <objectAdapter.h>#include <anonObject.h>#include <initialiser.h>#include <exceptiondefs.h>#include <omniORB4/omniInterceptors.h>#include <interceptors.h>#include <giopRope.h>#include <invoker.h>#include <orbOptions.h>#include <orbParameters.h>#include <omniORB4/objTracker.h>#include <corbaOrb.h>#ifdef __WIN32__# include <eh.h>#endif////////////////////////////////////////////////////////////////////////////// Configuration options //////////////////////////////////////////////////////////////////////////////CORBA::ULong omniORB::traceLevel = 1;// level 0 - critical errors only// level 1 - informational messages only// level 2 - configuration information and warnings// level 5 - the above plus report server thread creation and// communication socket shutdown// level 10 - the above plus execution trace messages// level 25 - output trace message per send or receive giop message// level 30 - dump up to 128 bytes of a giop message// level 40 - dump the complete giop message//// Valid values = (n >= 0)CORBA::Boolean omniORB::traceExceptions = 0;// If true, then system exceptions are logged when they are thrown.//// Valid values = 0 or 1CORBA::Boolean omniORB::traceInvocations = 0;// If true, then each local and remote invocation will generate a trace // message.//// Valid values = 0 or 1CORBA::Boolean omniORB::traceThreadId = 0;// If true, then the log messages will contain the thread id.//// Valid values = 0 or 1const CORBA::Char omni::myByteOrder = _OMNIORB_HOST_BYTE_ORDER_;omni_tracedmutex* omni::internalLock = 0;omni_tracedmutex* omni::poRcLock = 0;_CORBA_Unbounded_Sequence_Octet omni::myPrincipalID;const omni::alignment_t omni::max_alignment = omni::ALIGN_8;int omni::remoteInvocationCount = 0;int omni::localInvocationCount = 0;int omni::mainThreadId = 0;omni_tracedmutex* omni::objref_rc_lock = 0;// Protects omniObjRef reference counting and linked list.OMNI_USING_NAMESPACE(omni)CORBA::ULong orbParameters::objectTableSize = 0;// Hash table size of the Active Object Map. If this is zero, the ORB// uses a dynamically resized open hash table. This is normally the// best option, but it leads to less predictable performance since// any operation which adds or removes a table entry may trigger a// resize. If you set this to a non-zero value, the hash table has// the specified number of entries, and is never resized. Note that// the hash table is open, so this does not limit the number of// active objects, just how efficiently they can be located.//// Valid values = (n >= 0)// 0 --> use a dynamically resized table.CORBA::Boolean orbParameters::abortOnInternalError = 0;// If the value of this variable is TRUE then the ORB will abort// instead of throwing an exception when a fatal internal error is// detected. This is useful for debuging the ORB -- as the stack will// not be unwound by the exception handler, so a stack trace can be// obtained.// It is hoped that this will not often be needed by users of omniORB!//// Valid values = 0 or 1static CORBA::Boolean abortOnNativeException = 0;// On Windows, "native" exceptions such as segmentation faults and// divide by zero appear as C++ exceptions that can be caught with// catch (...). Setting this parameter to true causes such exceptions// to abort the process instead.//// Valid values = 0 or 1////////////////////////////////////////////////////////////////////////////#if defined(HAS_Cplusplus_Namespace)# ifndef __DMC__using omniORB::operator==;# endif#endifOMNI_NAMESPACE_BEGIN(omni)// The local object table. This is a dynamically resized// open hash table.static omniObjTableEntry** objectTable = 0;static _CORBA_ULong objectTableSize = 0;static int objectTableSizeI = 0;static _CORBA_ULong numObjectsInTable = 0;static _CORBA_ULong maxNumObjects = 0;static _CORBA_ULong minNumObjects = 0;// Some sort of magic numbers that are supposed// to be good for hash tables...static int objTblSizes[] = { 128 + 3, // 2^7 1024 + 9, // 2^10 8192 + 27, // 2^13 32768 + 3, // 2^15 65536 + 45, // 2^16 131072 + 9, 262144 + 39, 524288 + 39, 1048576 + 9, // 2^20 2097152 + 5, 4194304 + 3, 8388608 + 33, 16777216 + 27, 33554432 + 9, // 2^25 67108864 + 71, 134217728 + 39, 268435456 + 9, 536870912 + 5, 1073741824 + 83, // 2^30 -- I'd be suprised if this is exceeded! -1 // Sentinel to detect the end, just to be paranoid.};OMNI_NAMESPACE_END(omni)voidomniObjTable::resize(){ ASSERT_OMNI_TRACEDMUTEX_HELD(*omni::internalLock, 1); OMNIORB_ASSERT(numObjectsInTable > maxNumObjects || numObjectsInTable < minNumObjects && objectTableSizeI > 0); if (numObjectsInTable > maxNumObjects) { ++objectTableSizeI; } else if (numObjectsInTable < minNumObjects && objectTableSizeI > 0) { --objectTableSizeI; } else return; int newsizei = objTblSizes[objectTableSizeI]; if (newsizei == -1) { // Wow, we fell off the bottom of the table! If this happens, // I'll eat my hat... if (omniORB::trace(5)) { omniORB::logger l; l << "More than " << maxNumObjects << " active objects! " << "Consider extending the available object table sizes in " << __FILE__ << ".\n"; } objectTableSizeI--; maxNumObjects = 1ul << 31; return; } CORBA::ULong newsize = newsizei; if (omniORB::trace(15)) { omniORB::logger l; l << "Object table resizing from " << objectTableSize << " to " << newsize << "\n"; } // Create and initialise new object table. omniObjTableEntry** newtable = new omniObjTableEntry* [newsize]; CORBA::ULong i; for( i = 0; i < newsize; i++ ) newtable[i] = 0; // Move the objects across... for( i = 0; i < objectTableSize; i++ ) { omniObjTableEntry* id = objectTable[i]; while( id ) { omniObjTableEntry* next = id->nextInObjectTable(); _CORBA_ULong j = omni::hash(id->key(), id->keysize()) % newsize;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?