diff options
Diffstat (limited to 'TAO/tao/ORB_Core.cpp')
-rw-r--r-- | TAO/tao/ORB_Core.cpp | 420 |
1 files changed, 339 insertions, 81 deletions
diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index 3487f46ca0a..99877176ed8 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -99,7 +99,8 @@ TAO_ORB_Core_Static_Resources* TAO_ORB_Core_Static_Resources::instance_ = 0; // Force an instance to be created at module initialization time, // since we do not want to worry about double checked locking and // the race condition to initialize the lock. -TAO_ORB_Core_Static_Resources* TAO_ORB_Core_Static_Resources::initialization_reference_ = +TAO_ORB_Core_Static_Resources* +TAO_ORB_Core_Static_Resources::initialization_reference_ = TAO_ORB_Core_Static_Resources::instance (); TAO_ORB_Core_Static_Resources* @@ -126,7 +127,9 @@ TAO_ORB_Core_Static_Resources::TAO_ORB_Core_Static_Resources (void) timeout_hook_ (0), connection_timeout_hook_ (0), endpoint_selector_factory_name_ ("Default_Endpoint_Selector_Factory"), - thread_lane_resources_manager_factory_name_ ("Default_Thread_Lane_Resources_Manager_Factory"), + thread_lane_resources_manager_factory_name_ + ("Default_Thread_Lane_Resources_Manager_Factory"), + collocation_resolver_name_ ("Default_Collocation_Resolver"), stub_factory_name_ ("Default_Stub_Factory"), resource_factory_name_ ("Resource_Factory"), @@ -136,7 +139,13 @@ TAO_ORB_Core_Static_Resources::TAO_ORB_Core_Static_Resources (void) iorinterceptor_adapter_factory_name_ ("IORInterceptor_Adapter_Factory"), valuetype_adapter_factory_name_ ("valuetype_Adapter_Factory"), poa_factory_name_ ("TAO_Object_Adapter_Factory"), - poa_factory_directive_ (ACE_TEXT_TO_CHAR_IN (ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_Object_Adapter_Factory", "TAO_PortableServer", "_make_TAO_Object_Adapter_Factory", ""))) + poa_factory_directive_ + (ACE_TEXT_TO_CHAR_IN + (ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_Object_Adapter_Factory", + "TAO_PortableServer", + "_make_TAO_Object_Adapter_Factory", + ""))), + alt_connection_timeout_hook_ (0) { } @@ -252,6 +261,17 @@ TAO_ORB_Core::TAO_ORB_Core (const char *orbid) // Initialize the default request dispatcher. ACE_NEW (this->request_dispatcher_, TAO_Request_Dispatcher); + + /* + * @TODO: Get rid of the "magic number" for the Service repository size. + * Can this be dynamic container instead? + */ + if (ACE_OS::strnlen (this->orbid_, 1) == 0) + // (re)use the default/global getsalt + ACE_NEW (this->config_, ACE_Service_Gestalt); + else + ACE_NEW (this->config_, + ACE_Service_Gestalt (ACE_Service_Gestalt::MAX_SERVICES / 4)); } TAO_ORB_Core::~TAO_ORB_Core (void) @@ -288,6 +308,9 @@ TAO_ORB_Core::~TAO_ORB_Core (void) orbinitializer_registry_ = 0; ::CORBA::release (this->orb_); + + delete this->config_; + this->config_ = 0; } int @@ -338,6 +361,9 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) // Use SO_KEEPALIVE (default 0). int so_keepalive = 0; + // Use SO_DONTROUTE (default 0) + int so_dontroute = 0; + // Use dotted decimal addresses // @@ This option will be treated as a suggestion to each loaded // protocol to use a character representation for the numeric @@ -359,6 +385,8 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) int linger = -1; + int use_parallel_connects = 0; + // Copy command line parameter not to use original. ACE_Argv_Type_Converter command_line (argc, argv); @@ -455,6 +483,15 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) arg_shifter.consume_arg (); } else if (0 != (current_arg = arg_shifter.get_the_parameter + (ACE_LIB_TEXT("-ORBDontRoute")))) + { + // Use SO_DONTROUTE or not. + so_dontroute = + ACE_OS::atoi (current_arg); + + arg_shifter.consume_arg (); + } + else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ORBTradingServicePort")))) { // Specify the port number for the TradingService. @@ -878,7 +915,7 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) ACE_CString lane (ACE_TEXT_TO_CHAR_IN (current_arg)); arg_shifter.consume_arg (); - if(arg_shifter.is_option_next ()) + if (arg_shifter.is_option_next ()) return -1; ACE_CString endpoints (ACE_TEXT_TO_CHAR_IN (arg_shifter.get_current ())); @@ -915,6 +952,20 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) { negotiate_codesets = (ACE_OS::atoi (current_arg)); + + arg_shifter.consume_arg (); + } + else if ((current_arg = arg_shifter.get_the_parameter + (ACE_LIB_TEXT("-ORBUseParallelConnects")))) + { + use_parallel_connects = ACE_OS::atoi (current_arg); + arg_shifter.consume_arg (); + } + else if ((current_arg = arg_shifter.get_the_parameter + (ACE_LIB_TEXT("-ORBParallelConnectDelay")))) + { + this->orb_params ()->parallel_connect_delay + (ACE_OS::atoi (current_arg)); arg_shifter.consume_arg (); } else if (0 != (current_arg = arg_shifter.get_the_parameter @@ -962,7 +1013,8 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) ACE_DEBUG ((LM_ERROR, ACE_TEXT ("ERROR: Unknown \"-ORB\" option ") ACE_TEXT ("<%s>.\n"), - ((current_arg == 0) ? ACE_TEXT("<NULL>") : current_arg))); + ((current_arg == 0) ? ACE_TEXT("<NULL>") + : current_arg))); } ACE_THROW_RETURN (CORBA::BAD_PARAM ( @@ -996,7 +1048,8 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) if (TAO_debug_level > 0) { ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ERROR: Environment variable TAO_ORBENDPOINT set to invalid value ") + ACE_TEXT ("ERROR: Environment variable ") + ACE_TEXT ("TAO_ORBENDPOINT set to invalid value ") ACE_TEXT ("<%s>.\n"), env_endpoint)); } @@ -1022,6 +1075,7 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) (void) ACE_OS::signal (SIGPIPE, (ACE_SignalHandler) SIG_IGN); #endif /* SIGPIPE */ + // Calling the open method here so that the svc.conf file is // opened and TAO_default_resource_factory::init () is called by the // time this method is called. @@ -1155,9 +1209,14 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) this->orb_params ()->cache_incoming_by_dotted_decimal_address (no_server_side_name_lookups || dotted_decimal_addresses); + + this->orb_params ()->use_parallel_connects + (use_parallel_connects != 0); + this->orb_params ()->linger (linger); this->orb_params ()->nodelay (nodelay); this->orb_params ()->sock_keepalive (so_keepalive); + this->orb_params ()->sock_dontroute (so_dontroute); if (rcv_sock_size >= 0) this->orb_params ()->sock_rcvbuf_size (rcv_sock_size); if (snd_sock_size >= 0) @@ -1196,9 +1255,13 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) this->flushing_strategy_ = trf->create_flushing_strategy (); // Look in the service repository for an instance of the Protocol Hooks. + const ACE_CString &protocols_hooks_name = + TAO_ORB_Core_Static_Resources::instance ()->protocols_hooks_name_; + this->protocols_hooks_ = ACE_Dynamic_Service<TAO_Protocols_Hooks>::instance - (TAO_ORB_Core_Static_Resources::instance ()->protocols_hooks_name_.c_str()); + (this->configuration (), + ACE_TEXT_CHAR_TO_TCHAR (protocols_hooks_name.c_str())); // Must have valid protocol hooks. if (this->protocols_hooks_ == 0) @@ -1283,7 +1346,7 @@ TAO_ORB_Core::fini (void) if (this->thread_lane_resources_manager_ != 0) this->thread_lane_resources_manager_->finalize (); - (void) TAO::ORB::close_services (); + (void) TAO::ORB::close_services (this->configuration ()); // Destroy the object_key table this->object_key_table_.destroy (); @@ -1405,9 +1468,13 @@ TAO_ORB_Core::resource_factory (void) } // Look in the service repository for an instance. + ACE_CString &resource_factory_name = + TAO_ORB_Core_Static_Resources::instance ()->resource_factory_name_; + this->resource_factory_ = ACE_Dynamic_Service<TAO_Resource_Factory>::instance - (TAO_ORB_Core_Static_Resources::instance ()->resource_factory_name_.c_str()); + (this->configuration (), + ACE_TEXT_CHAR_TO_TCHAR (resource_factory_name.c_str())); return this->resource_factory_; } @@ -1427,9 +1494,13 @@ TAO_ORB_Core::thread_lane_resources_manager (void) return *this->thread_lane_resources_manager_; // If not, lookup the corresponding factory and ask it to make one. + const ACE_CString &thread_lane_resources_manager_factory_name = + TAO_ORB_Core_Static_Resources::instance ()->thread_lane_resources_manager_factory_name_; + TAO_Thread_Lane_Resources_Manager_Factory *factory = ACE_Dynamic_Service<TAO_Thread_Lane_Resources_Manager_Factory>::instance - (TAO_ORB_Core_Static_Resources::instance ()->thread_lane_resources_manager_factory_name_.c_str()); + (this->configuration (), + ACE_TEXT_CHAR_TO_TCHAR (thread_lane_resources_manager_factory_name.c_str())); this->thread_lane_resources_manager_ = factory->create_thread_lane_resources_manager (*this); @@ -1445,9 +1516,13 @@ TAO_ORB_Core::collocation_resolver (void) return *this->collocation_resolver_; // If not, lookup it up. + const ACE_CString &collocation_resolver_name = + TAO_ORB_Core_Static_Resources::instance ()->collocation_resolver_name_; + this->collocation_resolver_ = ACE_Dynamic_Service<TAO_Collocation_Resolver>::instance - (TAO_ORB_Core_Static_Resources::instance ()->collocation_resolver_name_.c_str()); + (this->configuration (), + ACE_TEXT_CHAR_TO_TCHAR (collocation_resolver_name.c_str())); return *this->collocation_resolver_; } @@ -1457,18 +1532,21 @@ TAO_ORB_Core::policy_factory_registry_i (void) { TAO_PolicyFactory_Registry_Factory *loader = - ACE_Dynamic_Service<TAO_PolicyFactory_Registry_Factory>::instance ( - "PolicyFactory_Loader"); + ACE_Dynamic_Service<TAO_PolicyFactory_Registry_Factory>::instance + (this->configuration (), + ACE_TEXT ("PolicyFactory_Loader")); + if (loader == 0) { - ACE_Service_Config::process_directive ( + this->configuration ()->process_directive ( ACE_DYNAMIC_SERVICE_DIRECTIVE("PolicyFactory_Loader", "TAO_PI", - "_make_PolicyFactory_Loader", + "_make_TAO_PolicyFactory_Loader", "")); loader = - ACE_Dynamic_Service<TAO_PolicyFactory_Registry_Factory>::instance ( - "PolicyFactory_Loader"); + ACE_Dynamic_Service<TAO_PolicyFactory_Registry_Factory>::instance + (this->configuration (), + ACE_TEXT ("PolicyFactory_Loader")); } if (loader != 0) @@ -1486,7 +1564,8 @@ TAO_ORB_Core::orbinitializer_registry_i (void) // If not, lookup it up. this->orbinitializer_registry_ = ACE_Dynamic_Service<TAO::ORBInitializer_Registry_Adapter>::instance - ("ORBInitializer_Registry"); + (this->configuration (), + ACE_TEXT ("ORBInitializer_Registry")); #if !defined (TAO_AS_STATIC_LIBS) // In case we build shared, try to load the PI Client library, in a @@ -1494,14 +1573,15 @@ TAO_ORB_Core::orbinitializer_registry_i (void) // output an error then. if (orbinitializer_registry_ == 0) { - ACE_Service_Config::process_directive ( + this->configuration ()->process_directive ( ACE_DYNAMIC_SERVICE_DIRECTIVE("ORBInitializer_Registry", "TAO_PI", "_make_ORBInitializer_Registry", "")); orbinitializer_registry_ = ACE_Dynamic_Service<TAO::ORBInitializer_Registry_Adapter>::instance - ("ORBInitializer_Registry"); + (this->configuration (), + ACE_TEXT ("ORBInitializer_Registry")); } #endif /* !TAO_AS_STATIC_LIBS */ @@ -1516,9 +1596,13 @@ TAO_ORB_Core::stub_factory (void) return this->stub_factory_; // If not, look in the service repository for an instance. + const ACE_CString &stub_factory_name = + TAO_ORB_Core_Static_Resources::instance ()->stub_factory_name_; + this->stub_factory_ = ACE_Dynamic_Service<TAO_Stub_Factory>::instance - (TAO_ORB_Core_Static_Resources::instance ()->stub_factory_name_.c_str()); + (this->configuration (), + ACE_TEXT_CHAR_TO_TCHAR (stub_factory_name.c_str())); return this->stub_factory_; } @@ -1554,9 +1638,13 @@ TAO_ORB_Core::endpoint_selector_factory (void) return this->endpoint_selector_factory_; // If not, look in the service repository for an instance. + const ACE_CString &endpoint_selector_factory_name = + TAO_ORB_Core_Static_Resources::instance ()->endpoint_selector_factory_name_; + this->endpoint_selector_factory_ = ACE_Dynamic_Service<TAO_Endpoint_Selector_Factory>::instance - (TAO_ORB_Core_Static_Resources::instance ()->endpoint_selector_factory_name_.c_str()); + (this->configuration (), + ACE_TEXT_CHAR_TO_TCHAR (endpoint_selector_factory_name.c_str())); return this->endpoint_selector_factory_; } @@ -1642,7 +1730,9 @@ TAO_ORB_Core::client_factory (void) { // Look in the service repository for an instance. this->client_factory_ = - ACE_Dynamic_Service<TAO_Client_Strategy_Factory>::instance ("Client_Strategy_Factory"); + ACE_Dynamic_Service<TAO_Client_Strategy_Factory>::instance + (this->configuration (), + ACE_TEXT ("Client_Strategy_Factory")); } return this->client_factory_; @@ -1655,7 +1745,9 @@ TAO_ORB_Core::server_factory (void) { // Look in the service repository for an instance. this->server_factory_ = - ACE_Dynamic_Service<TAO_Server_Strategy_Factory>::instance ("Server_Strategy_Factory"); + ACE_Dynamic_Service<TAO_Server_Strategy_Factory>::instance + (this->configuration (), + ACE_TEXT ("Server_Strategy_Factory")); } return this->server_factory_; @@ -1667,20 +1759,28 @@ TAO_ORB_Core::root_poa (ACE_ENV_SINGLE_ARG_DECL) // DCL .. if (CORBA::is_nil (this->root_poa_.in ())) { + + // Making sure the initialization process in the current thread uses + // the correct service repository (ours), instead of the global one. + ACE_Service_Config_Guard scg (this->configuration ()); + + TAO_ORB_Core_Static_Resources* static_resources = TAO_ORB_Core_Static_Resources::instance (); TAO_Adapter_Factory *factory = - ACE_Dynamic_Service<TAO_Adapter_Factory>::instance ( + ACE_Dynamic_Service<TAO_Adapter_Factory>::instance + (this->configuration (), static_resources->poa_factory_name_.c_str()); if (factory == 0) { - ACE_Service_Config::process_directive ( - ACE_TEXT_TO_TCHAR_IN ( + this->configuration()->process_directive (ACE_TEXT_TO_TCHAR_IN ( static_resources->poa_factory_directive_.c_str())); + factory = - ACE_Dynamic_Service<TAO_Adapter_Factory>::instance ( + ACE_Dynamic_Service<TAO_Adapter_Factory>::instance + (this->configuration (), static_resources->poa_factory_name_.c_str()); } @@ -1799,7 +1899,8 @@ TAO_ORB_Core::load_policy_validators (TAO_Policy_Validator &validator if (this->bidir_adapter_ == 0) { this->bidir_adapter_ = - ACE_Dynamic_Service<TAO_BiDir_Adapter>::instance ("BiDirGIOP_Loader"); + ACE_Dynamic_Service<TAO_BiDir_Adapter>::instance + (this->configuration (), ACE_TEXT ("BiDirGIOP_Loader")); } // Call the BiDir library if it has been loaded @@ -1983,6 +2084,8 @@ TAO_ORB_Core::run (ACE_Time_Value *tv, int perform_work ACE_ENV_ARG_DECL_NOT_USED) { + ACE_Service_Config_Guard guard (this->configuration()); + if (TAO_debug_level > 2) { ACE_DEBUG ((LM_DEBUG, @@ -2067,6 +2170,7 @@ TAO_ORB_Core::run (ACE_Time_Value *tv, // A timeout, terminate the loop... break; } + if (perform_work) { // This is running on behalf of a perform_work() call, @@ -2171,8 +2275,7 @@ TAO_ORB_Core::destroy (ACE_ENV_SINGLE_ARG_DECL) // // Shutdown the ORB and block until the shutdown is complete. - this->shutdown (1 - ACE_ENV_ARG_PARAMETER); + this->shutdown (1 ACE_ENV_ARG_PARAMETER); ACE_CHECK; // Invoke Interceptor::destroy() on all registered interceptors. @@ -2201,7 +2304,6 @@ TAO_ORB_Core::check_shutdown (ACE_ENV_SINGLE_ARG_DECL) void TAO_ORB_Core::destroy_interceptors (ACE_ENV_SINGLE_ARG_DECL) { - ACE_TRY { ACE_GUARD (TAO_SYNCH_MUTEX, monitor, this->lock_); @@ -2264,19 +2366,28 @@ void TAO_ORB_Core::resolve_typecodefactory_i (ACE_ENV_SINGLE_ARG_DECL) { TAO_Object_Loader *loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("TypeCodeFactory_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("TypeCodeFactory_Loader")); + +#if !defined(TAO_AS_STATIC_LIBS) if (loader == 0) { - ACE_Service_Config::process_directive ( - ACE_DYNAMIC_SERVICE_DIRECTIVE("TypeCodeFactory_Loader", + this->configuration ()->process_directive ( + ACE_DYNAMIC_SERVICE_DIRECTIVE("TypeCodeFactory", "TAO_TypeCodeFactory", "_make_TAO_TypeCodeFactory_Loader", "")); loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("TypeCodeFactory_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("TypeCodeFactory_Loader")); + if (loader == 0) ACE_THROW (CORBA::ORB::InvalidName ()); } +#endif /* !defined (TAO_AS_STATIC_LIBS) */ + this->typecode_factory_ = loader->create_object (this->orb_, 0, 0 ACE_ENV_ARG_PARAMETER); } @@ -2285,17 +2396,26 @@ void TAO_ORB_Core::resolve_codecfactory_i (ACE_ENV_SINGLE_ARG_DECL) { TAO_Object_Loader *loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("CodecFactory_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("CodecFactory_Loader")); + +#if !defined(TAO_AS_STATIC_LIBS) if (loader == 0) { - ACE_Service_Config::process_directive ( - ACE_DYNAMIC_SERVICE_DIRECTIVE("CodecFactory_Loader", + this->configuration()->process_directive ( + ACE_DYNAMIC_SERVICE_DIRECTIVE("CodecFactory", "TAO_CodecFactory", "_make_TAO_CodecFactory_Loader", "")); loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("CodecFactory_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("CodecFactory_Loader")); + } +#endif /* !defined (TAO_AS_STATIC_LIBS) */ + if (loader != 0) { this->codec_factory_ = @@ -2308,17 +2428,29 @@ void TAO_ORB_Core::resolve_poa_current_i (ACE_ENV_SINGLE_ARG_DECL) { TAO_Object_Loader *loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("TAO_POA_Current_Factory"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration(), + ACE_TEXT ("TAO_POA_Current_Factory")); + +#if !defined(TAO_AS_STATIC_LIBS) if (loader == 0) { - ACE_Service_Config::process_directive ( + this->configuration()->process_directive ( ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_POA_Current_Factory", "TAO_PortableServer", "_make_TAO_POA_Current_Factory", "")); loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("TAO_POA_Current_Factory"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration(), + ACE_TEXT ("TAO_POA_Current_Factory")); } + + if (loader == 0) + ACE_THROW (CORBA::ORB::InvalidName ()); + +#endif /* !defined (TAO_AS_STATIC_LIBS) */ + if (loader != 0) { this->poa_current_ = @@ -2333,17 +2465,24 @@ void TAO_ORB_Core::resolve_picurrent_i (ACE_ENV_SINGLE_ARG_DECL) { TAO_Object_Loader *loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("PICurrent_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("PICurrent_Loader")); + +#if !defined(TAO_AS_STATIC_LIBS) if (loader == 0) { - ACE_Service_Config::process_directive ( + this->configuration ()->process_directive ( ACE_DYNAMIC_SERVICE_DIRECTIVE("PICurrent_Loader", "TAO_PI", "_make_TAO_PICurrent_Loader", "")); loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("PICurrent_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("PICurrent_Loader")); } +#endif /* !defined (TAO_AS_STATIC_LIBS) */ if (loader != 0) { @@ -2362,17 +2501,24 @@ void TAO_ORB_Core::resolve_dynanyfactory_i (ACE_ENV_SINGLE_ARG_DECL) { TAO_Object_Loader *loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("DynamicAny_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("DynamicAny_Loader")); + +#if !defined(TAO_AS_STATIC_LIBS) if (loader == 0) { - ACE_Service_Config::process_directive ( + this->configuration ()->process_directive ( ACE_DYNAMIC_SERVICE_DIRECTIVE("DynamicAny_Loader", "TAO_DynamicAny", "_make_TAO_DynamicAny_Loader", "")); loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("DynamicAny_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("DynamicAny_Loader")); } +#endif /* !defined (TAO_AS_STATIC_LIBS) */ if (loader != 0) { @@ -2386,18 +2532,25 @@ void TAO_ORB_Core::resolve_iormanipulation_i (ACE_ENV_SINGLE_ARG_DECL) { TAO_Object_Loader *loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("IORManip_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("IORManip_Loader")); +#if !defined(TAO_AS_STATIC_LIBS) if (loader == 0) { - ACE_Service_Config::process_directive ( + this->configuration()->process_directive ( ACE_DYNAMIC_SERVICE_DIRECTIVE("IORManip_Loader", "TAO_IORManip", "_make_TAO_IORManip_Loader", "")); loader = - ACE_Dynamic_Service<TAO_Object_Loader>::instance ("IORManip_Loader"); + ACE_Dynamic_Service<TAO_Object_Loader>::instance + (this->configuration (), + ACE_TEXT ("IORManip_Loader")); } +#endif /* !defined (TAO_AS_STATIC_LIBS) */ + if (loader != 0) { this->ior_manip_factory_ = @@ -2410,29 +2563,39 @@ void TAO_ORB_Core::resolve_ior_table_i (ACE_ENV_SINGLE_ARG_DECL) { TAO_Adapter_Factory *factory = - ACE_Dynamic_Service<TAO_Adapter_Factory>::instance ("TAO_IORTable"); + ACE_Dynamic_Service<TAO_Adapter_Factory>::instance + (this->configuration (), + ACE_TEXT ("TAO_IORTable")); + +#if !defined(TAO_AS_STATIC_LIBS) if (factory == 0) { - ACE_Service_Config::process_directive ( + this->configuration ()->process_directive ( ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_IORTable", "TAO_IORTable", "_make_TAO_Table_Adapter_Factory", "")); factory = - ACE_Dynamic_Service<TAO_Adapter_Factory>::instance ("TAO_IORTable"); + ACE_Dynamic_Service<TAO_Adapter_Factory>::instance + (this->configuration (), + ACE_TEXT ("TAO_IORTable")); } +#endif /* !defined (TAO_AS_STATIC_LIBS) */ if (factory != 0) { - // @@ Not exception safe - TAO_Adapter *iortable_adapter = factory->create (this); - this->adapter_registry_.insert (iortable_adapter ACE_ENV_ARG_PARAMETER); + ACE_Auto_Ptr <TAO_Adapter> iortable_adapter (factory->create (this)); + iortable_adapter->open (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; - iortable_adapter->open (ACE_ENV_SINGLE_ARG_PARAMETER); + CORBA::Object_var tmp_root = iortable_adapter->root (); + + this->adapter_registry_.insert (iortable_adapter.get () ACE_ENV_ARG_PARAMETER); ACE_CHECK; - this->ior_table_ = iortable_adapter->root (); + // It is now (exception) safe to release ownership from the auto pointers + this->ior_table_= tmp_root._retn (); + iortable_adapter.release (); } } @@ -2709,7 +2872,8 @@ TAO_ORB_Core::implrepo_service (void) ACE_TRY_NEW_ENV { - CORBA::Object_var temp = this->orb_->resolve_initial_references ("ImplRepoService" ACE_ENV_ARG_PARAMETER); + CORBA::Object_var temp = + this->orb_->resolve_initial_references ("ImplRepoService" ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::Object::_nil ()); @@ -2719,7 +2883,8 @@ TAO_ORB_Core::implrepo_service (void) } ACE_CATCHANY { - // Just make sure that we have a null pointer. Ignore the exception anyway. + // Just make sure that we have a null pointer. Ignore the exception + // anyway. this->implrepo_service_ = CORBA::Object::_nil (); } ACE_ENDTRY; @@ -2803,15 +2968,77 @@ TAO_ORB_Core::call_timeout_hook (TAO_Stub *stub, return; } (*timeout_hook) (this, stub, has_timeout, time_value); + + Timeout_Hook alt_connection_timeout_hook = + TAO_ORB_Core_Static_Resources::instance ()->alt_connection_timeout_hook_; + + if (alt_connection_timeout_hook == 0) + return; + + if (!has_timeout || time_value == ACE_Time_Value::zero ) + { + (*alt_connection_timeout_hook) (this, stub, has_timeout,time_value); + return; + } + + // At this point, both the primary and alternate hooks are defined, and + // the primary did indeed set a value + ACE_Time_Value tv1; + bool ht1; + (*alt_connection_timeout_hook) (this, stub, ht1,tv1); + if (ht1 && tv1 > ACE_Time_Value::zero && tv1 < time_value) + time_value = tv1; } void TAO_ORB_Core::set_timeout_hook (Timeout_Hook hook) { // Saving the hook pointer so that we can use it later when needed. - TAO_ORB_Core_Static_Resources::instance ()->timeout_hook_ = hook; + // For now there are only two entry points that may supply a connection + // timeout hook. But there might be future entry points, so this should + // probably be addressed by a more sophisticated mechanism. + +#define TOCSRi TAO_ORB_Core_Static_Resources::instance () + + // A consern was raised that since this function is called by two + // different initializers there may be a race condition that might + // require a lock. We are not using a lock at this time because of + // two callers, one happens only during service directive processing + // and the other only during ORB Initialization time. The former + // happens when the OC_Endpoint_Selector_Factory is loaded, the + // latter is part of the messaging library. The messaging library + // calls this function as part of pre_init processing, and this call + // happes for every ORB instance. This was the case before these The + // latter call occurs when the messaging library is loaded. The + // redundant calls occured then as well. Second, it isn't clear how + // a lock in this static method would react in the face of windows + // dlls, shared memory segments, etc. Therefore we are continuing to + // keep this code lockless as it always was, assuming no + // simultanious overwrite will occur. + + if (TOCSRi->connection_timeout_hook_ == 0) + { + if (TAO_debug_level > 2) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("TAO (%P|%t) setting primary hook\n"))); + TOCSRi->connection_timeout_hook_ = hook; + } + else if (TOCSRi->connection_timeout_hook_ != hook && + TOCSRi->alt_connection_timeout_hook_ == 0) + { + if (TAO_debug_level > 2) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("TAO (%P|%t) setting alternate hook\n"))); + TOCSRi->alt_connection_timeout_hook_ = hook; + } + else + if (TAO_debug_level > 2) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) not overwriting alternate hook.") + ACE_TEXT (" Is it still null? %d\n"), + TOCSRi->alt_connection_timeout_hook_ == 0)); - return; +#undef TOCSRi } void @@ -2991,16 +3218,38 @@ TAO_ORB_Core::ior_interceptor_adapter (void) ACE_TRY { TAO_IORInterceptor_Adapter_Factory * ior_ap_factory = - ACE_Dynamic_Service<TAO_IORInterceptor_Adapter_Factory>::instance ( - TAO_ORB_Core::iorinterceptor_adapter_factory_name () - ); + ACE_Dynamic_Service<TAO_IORInterceptor_Adapter_Factory>::instance + (this->configuration (), + ACE_TEXT_CHAR_TO_TCHAR (TAO_ORB_Core::iorinterceptor_adapter_factory_name ())); - if (ior_ap_factory) +#if !defined (TAO_AS_STATIC_LIBS) + // In case we build shared, try to load the IOR_Interceptor factory. In a + // static build we just can't do this, so don't try it + if (ior_ap_factory == 0) + { + this->configuration()->process_directive + (ACE_DYNAMIC_SERVICE_DIRECTIVE("Concrete_IORInterceptor_Adapter_Factory", + "TAO_IORInterceptor", + "_make_TAO_IORInterceptor_Adapter_Factory_Impl", + "")); + ior_ap_factory = + ACE_Dynamic_Service<TAO_IORInterceptor_Adapter_Factory>::instance + (this->configuration (), ACE_TEXT("Concrete_IORInterceptor_Adapter_Factory")); + } +#endif /* !TAO_AS_STATIC_LIBS */ + + if (ior_ap_factory == 0) { - this->ior_interceptor_adapter_ = - ior_ap_factory->create (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%P|%t) Unable to get a IORInterceptor factory\n")), + 0); + ACE_THROW (CORBA::INTERNAL ()); } + + this->ior_interceptor_adapter_ = + ior_ap_factory->create (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } ACE_CATCHANY { @@ -3034,7 +3283,8 @@ TAO_ORB_Core::add_interceptor ( ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("ERROR: ORB Core unable to find the ") - ACE_TEXT ("Client Request Interceptor Adapter Factory instance"))); + ACE_TEXT ("Client Request Interceptor Adapter Factory ") + ACE_TEXT ("instance"))); ACE_THROW (CORBA::INTERNAL ()); } @@ -3053,9 +3303,9 @@ TAO_ORB_Core::clientrequestinterceptor_adapter_i (void) if (this->client_request_interceptor_adapter_ == 0) { TAO_ClientRequestInterceptor_Adapter_Factory *factory = - ACE_Dynamic_Service<TAO_ClientRequestInterceptor_Adapter_Factory>::instance ( - "ClientRequestInterceptor_Adapter_Factory" - ); + ACE_Dynamic_Service<TAO_ClientRequestInterceptor_Adapter_Factory>::instance + (this->configuration (), + ACE_TEXT ("ClientRequestInterceptor_Adapter_Factory")); if (factory) { @@ -3084,7 +3334,8 @@ TAO_ORB_Core::add_interceptor ( ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("ERROR: ORB Core unable to find the ") - ACE_TEXT ("Server Request Interceptor Adapter Factory instance"))); + ACE_TEXT ("Server Request Interceptor Adapter Factory ") + ACE_TEXT ("instance"))); ACE_THROW (CORBA::INTERNAL ()); } @@ -3110,7 +3361,8 @@ TAO_ORB_Core::add_interceptor ( ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("ERROR: ORB Core unable to find the ") - ACE_TEXT ("Client Request Interceptor Adapter Factory instance"))); + ACE_TEXT ("Client Request Interceptor Adapter Factory ") + ACE_TEXT ("instance"))); ACE_THROW (CORBA::INTERNAL ()); } @@ -3136,7 +3388,8 @@ TAO_ORB_Core::add_interceptor ( ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("ERROR: ORB Core unable to find the ") - ACE_TEXT ("Server Request Interceptor Adapter Factory instance"))); + ACE_TEXT ("Server Request Interceptor Adapter Factory ") + ACE_TEXT ("instance"))); ACE_THROW (CORBA::INTERNAL ()); } @@ -3155,9 +3408,9 @@ TAO_ORB_Core::serverrequestinterceptor_adapter_i (void) if (this->server_request_interceptor_adapter_ == 0) { TAO_ServerRequestInterceptor_Adapter_Factory *factory = - ACE_Dynamic_Service<TAO_ServerRequestInterceptor_Adapter_Factory>::instance ( - "ServerRequestInterceptor_Adapter_Factory" - ); + ACE_Dynamic_Service<TAO_ServerRequestInterceptor_Adapter_Factory>::instance + (this->configuration (), + ACE_TEXT ("ServerRequestInterceptor_Adapter_Factory")); if (factory) { @@ -3167,6 +3420,11 @@ TAO_ORB_Core::serverrequestinterceptor_adapter_i (void) } } + if (TAO_debug_level > 2) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) Server request interceptor adapter list at %@\n"), + this->server_request_interceptor_adapter_)); + return this->server_request_interceptor_adapter_; } |