diff options
Diffstat (limited to 'TAO/tao/default_resource.cpp')
-rw-r--r-- | TAO/tao/default_resource.cpp | 333 |
1 files changed, 115 insertions, 218 deletions
diff --git a/TAO/tao/default_resource.cpp b/TAO/tao/default_resource.cpp index 7b71d6bc03e..41c8b06c78a 100644 --- a/TAO/tao/default_resource.cpp +++ b/TAO/tao/default_resource.cpp @@ -1,19 +1,10 @@ // $Id$ #include "tao/default_resource.h" -#include "tao/Client_Strategy_Factory.h" -#include "tao/ORB_Core.h" -#include "tao/debug.h" -#include "tao/IIOP_Factory.h" -#include "tao/UIOP_Factory.h" - #include "ace/Select_Reactor.h" -#include "ace/XtReactor.h" -#include "ace/FlReactor.h" -#include "ace/WFMO_Reactor.h" -#include "ace/Msg_WFMO_Reactor.h" -#include "ace/Dynamic_Service.h" #include "ace/Arg_Shifter.h" +#include "tao/Client_Strategy_Factory.h" +#include "tao/ORB_Core.h" #if !defined (__ACE_INLINE__) # include "tao/default_resource.i" @@ -24,7 +15,8 @@ ACE_RCSID(tao, default_resource, "$Id$") TAO_Default_Resource_Factory::TAO_Default_Resource_Factory (void) : resource_source_ (TAO_GLOBAL), poa_source_ (TAO_GLOBAL), - reactor_type_ (TAO_REACTOR_SELECT_MT), + collocation_table_source_ (TAO_GLOBAL), + reactor_lock_ (TAO_TOKEN), cdr_allocator_source_ (TAO_GLOBAL) { } @@ -87,71 +79,30 @@ TAO_Default_Resource_Factory::init (int argc, char **argv) } else if (ACE_OS::strcmp (argv[curarg], "-ORBreactorlock") == 0) { - ACE_DEBUG ((LM_DEBUG, - "TAO_Default_Resource obsolete -ORBreactorlock " - "option, please use -ORBreactortype\n")); curarg++; if (curarg < argc) { char *name = argv[curarg]; if (ACE_OS::strcasecmp (name, "null") == 0) - reactor_type_ = TAO_REACTOR_SELECT_MT; + reactor_lock_ = TAO_NULL_LOCK; else if (ACE_OS::strcasecmp (name, "token") == 0) - reactor_type_= TAO_REACTOR_SELECT_ST; + reactor_lock_= TAO_TOKEN; } } - - else if (ACE_OS::strcmp (argv[curarg], "-ORBreactortype") == 0) + else if (ACE_OS::strcmp (argv[curarg], "-ORBcoltable") == 0) { curarg++; if (curarg < argc) { char *name = argv[curarg]; - if (ACE_OS::strcasecmp (name, "select_mt") == 0) - reactor_type_ = TAO_REACTOR_SELECT_MT; - else if (ACE_OS::strcasecmp (name, "select_st") == 0) - reactor_type_ = TAO_REACTOR_SELECT_ST; - else if (ACE_OS::strcasecmp (name, "fl_reactor") == 0) -#if defined(ACE_HAS_FL) - reactor_type_ = TAO_REACTOR_FL; -#else - ACE_DEBUG ((LM_DEBUG, - "TAO_Default_Factory - FlReactor" - " not supported on this platform\n")); -#endif /* ACE_HAS_FL */ - else if (ACE_OS::strcasecmp (name, "xt_reactor") == 0) -#if defined(ACE_HAS_XT) - reactor_type_ = TAO_REACTOR_XT; -#else - ACE_DEBUG ((LM_DEBUG, - "TAO_Default_Factory - XtReactor" - " not supported on this platform\n")); -#endif /* ACE_HAS_XT */ - else if (ACE_OS::strcasecmp (name, "WFMO") == 0) -#if defined(ACE_WIN32) - reactor_type_ = TAO_REACTOR_WFMO; -#else - ACE_DEBUG ((LM_DEBUG, - "TAO_Default_Factory - WFMO Reactor" - " not supported on this platform\n")); -#endif /* ACE_WIN32 */ - else if (ACE_OS::strcasecmp (name, "MsgWFMO") == 0) -#if defined(ACE_WIN32) - reactor_type_ = TAO_REACTOR_MSGWFMO; -#else - ACE_DEBUG ((LM_DEBUG, - "TAO_Default_Factory - MsgWFMO Reactor" - " not supported on this platform\n")); -#endif /* ACE_WIN32 */ - else - ACE_DEBUG ((LM_DEBUG, - "TAO_Default_Factory - unknown argument" - " <%s> for -ORBreactortype\n", name)); + if (ACE_OS::strcasecmp (name, "global") == 0) + collocation_table_source_ = TAO_GLOBAL; + else if (ACE_OS::strcasecmp (name, "orb") == 0) + collocation_table_source_ = TAO_TSS; } } - else if (ACE_OS::strcmp (argv[curarg], "-ORBinputcdrallocator") == 0) { curarg++; @@ -165,20 +116,6 @@ TAO_Default_Resource_Factory::init (int argc, char **argv) this->cdr_allocator_source_ = TAO_TSS; } } - else if (ACE_OS::strcmp (argv[curarg], "-ORBprotocolfactory") == 0) - { - TAO_ProtocolFactorySet *pset = this->get_protocol_factories (); - curarg++; - if (curarg < argc) - { - TAO_Protocol_Item *item = new TAO_Protocol_Item (argv[curarg]); - if (pset->insert (item) == -1) - { - ACE_ERROR ((LM_ERROR, - "(%P|%t) Unable to add protocol factories for %s: %p\n", argv[curarg])); - } - } - } // Don't allow a global ORB and a tss POA. if ( (local_resource_source == TAO_GLOBAL) && @@ -205,105 +142,6 @@ TAO_Default_Resource_Factory::init (int argc, char **argv) return 0; } -int -TAO_Default_Resource_Factory::init_protocol_factories (void) -{ - TAO_ProtocolFactorySetItor end = protocol_factories_.end (); - TAO_ProtocolFactorySetItor factory = protocol_factories_.begin (); - - // @@ Ossama, if you want to be very paranoid, you could get memory leak - // if insert operations failed. - - if (factory == end) - { - TAO_Protocol_Factory *protocol_factory = 0; - TAO_Protocol_Item *item = 0; - - protocol_factory = - ACE_Dynamic_Service<TAO_Protocol_Factory>::instance ("IIOP_Factory"); - - if (protocol_factory == 0) - { - if (TAO_orbdebug) - ACE_ERROR ((LM_WARNING, - "(%P|%t) WARNING - No %s found in Service Repository." - " Using default instance.\n", - "IIOP Protocol Factory")); - - ACE_NEW_RETURN (protocol_factory, - TAO_IIOP_Protocol_Factory, - -1); - } - - ACE_NEW_RETURN (item, TAO_Protocol_Item ("IIOP_Factory"), -1); - item->factory (protocol_factory); - - this->protocol_factories_.insert (item); - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - "TAO (%P|%t) Loaded default protocol <IIOP_Factory>\n")); - } - -#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) - protocol_factory = - ACE_Dynamic_Service<TAO_Protocol_Factory>::instance ("UIOP_Factory"); - - if (protocol_factory == 0) - { - if (TAO_orbdebug) - ACE_ERROR ((LM_WARNING, - "(%P|%t) WARNING - No %s found in Service Repository." - " Using default instance.\n", - "UIOP Protocol Factory")); - - ACE_NEW_RETURN (protocol_factory, - TAO_UIOP_Protocol_Factory, - -1); - } - - ACE_NEW_RETURN (item, TAO_Protocol_Item ("UIOP_Factory"), -1); - item->factory (protocol_factory); - - this->protocol_factories_.insert (item); - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - "TAO (%P|%t) Loaded default protocol <UIOP_Factory>\n")); - } -#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ - return 0; - } - - for ( ; factory != end ; factory++) - { - const ACE_CString& name = (*factory)->protocol_name (); - (*factory)->factory ( - ACE_Dynamic_Service<TAO_Protocol_Factory>::instance (name.c_str ())); - if ((*factory)->factory () == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "TAO (%P|%t) Unable to load protocol <%s>, %p\n", - name.c_str (), ""), - -1); - } - - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - "TAO (%P|%t) Loaded protocol <%s>\n", - name.c_str ())); - } - } - return 0; -} - -TAO_ProtocolFactorySet * -TAO_Default_Resource_Factory::get_protocol_factories (void) -{ - return &protocol_factories_; -} - #define IMPLEMENT_GET_METHOD(methodname,rtype,membername)\ rtype TAO_Default_Resource_Factory::methodname(void)\ {\ @@ -318,55 +156,16 @@ rtype TAO_Default_Resource_Factory::methodname(void)\ } IMPLEMENT_GET_METHOD(get_thr_mgr, ACE_Thread_Manager *, tm_) -IMPLEMENT_GET_METHOD(get_acceptor_registry, TAO_Acceptor_Registry *, ar_) +IMPLEMENT_GET_METHOD(get_acceptor, TAO_Acceptor *, a_) IMPLEMENT_GET_METHOD(get_connector_registry, TAO_Connector_Registry *, cr_) +IMPLEMENT_GET_METHOD(get_connector, TAO_Connector *, c_) +IMPLEMENT_GET_METHOD(get_null_creation_strategy, TAO_NULL_CREATION_STRATEGY *, null_creation_strategy_) +IMPLEMENT_GET_METHOD(get_null_activation_strategy, TAO_NULL_ACTIVATION_STRATEGY *, null_activation_strategy_) // @@ TODO We may be changing the state of the global // Allocated_Resources structure, but without any locks? // It seems to be done all over the place. -ACE_Reactor_Impl* -TAO_Default_Resource_Factory::allocate_reactor_impl (void) const -{ - ACE_Reactor_Impl *impl = 0; - switch (this->reactor_type_) - { - default: - case TAO_REACTOR_SELECT_MT: - ACE_NEW_RETURN (impl, TAO_REACTOR, 0); - break; - - case TAO_REACTOR_SELECT_ST: - ACE_NEW_RETURN (impl, TAO_NULL_LOCK_REACTOR, 0); - break; - - case TAO_REACTOR_FL: -#if defined(ACE_HAS_FL) - ACE_NEW_RETURN (impl, ACE_FlReactor, 0); -#endif /* ACE_HAS_FL */ - break; - - case TAO_REACTOR_XT: -#if defined(ACE_HAS_XT) - ACE_NEW_RETURN (impl, ACE_XtReactor, 0); -#endif /* ACE_HAS_FL */ - break; - - case TAO_REACTOR_WFMO: -#if defined(ACE_WIN32) && !defined (ACE_HAS_WINCE) - ACE_NEW_RETURN (impl, ACE_WFMO_Reactor, 0); -#endif /* ACE_WIN32 && !ACE_HAS_WINCE */ - break; - - case TAO_REACTOR_MSGWFMO: -#if defined(ACE_WIN32) - ACE_NEW_RETURN (impl, ACE_Msg_WFMO_Reactor, 0); -#endif /* ACE_WIN32 && !ACE_HAS_WINCE */ - break; - } - return impl; -} - ACE_Reactor * TAO_Default_Resource_Factory::get_reactor (void) { @@ -376,7 +175,7 @@ TAO_Default_Resource_Factory::get_reactor (void) if (GLOBAL_ALLOCATED::instance ()->r_ == 0) { ACE_NEW_RETURN (GLOBAL_ALLOCATED::instance ()->r_, - ACE_Reactor (this->allocate_reactor_impl (), 1), + TAO_Default_Reactor (this->reactor_lock ()), 0); } return GLOBAL_ALLOCATED::instance ()->r_; @@ -385,7 +184,7 @@ TAO_Default_Resource_Factory::get_reactor (void) if (TSS_ALLOCATED::instance ()->r_ == 0) { ACE_NEW_RETURN (TSS_ALLOCATED::instance ()->r_, - ACE_Reactor (this->allocate_reactor_impl (), 1), + TAO_Default_Reactor (this->reactor_lock ()), 0); } return TSS_ALLOCATED::instance ()->r_; @@ -424,6 +223,34 @@ TAO_Default_Resource_Factory::object_adapter (void) return 0; } +TAO_CACHED_CONNECT_STRATEGY * +TAO_Default_Resource_Factory::get_cached_connect_strategy (void) +{ + // @@ Remove this use of ORB_Core_instance() from here!!!! + switch (this->resource_source_) + { + case TAO_GLOBAL: + if (GLOBAL_ALLOCATED::instance ()->cached_connect_strategy_ == 0) + { + ACE_NEW_RETURN (GLOBAL_ALLOCATED::instance ()->cached_connect_strategy_, + TAO_CACHED_CONNECT_STRATEGY (TAO_ORB_Core_instance ()->client_factory ()->create_client_creation_strategy ()), + 0); + } + return GLOBAL_ALLOCATED::instance ()->cached_connect_strategy_; + ACE_NOTREACHED (break); + case TAO_TSS: + if (TSS_ALLOCATED::instance ()->cached_connect_strategy_ == 0) + { + ACE_NEW_RETURN (TSS_ALLOCATED::instance ()->cached_connect_strategy_, + TAO_CACHED_CONNECT_STRATEGY (TAO_ORB_Core_instance ()->client_factory ()->create_client_creation_strategy ()), + 0); + } + return TSS_ALLOCATED::instance ()->cached_connect_strategy_; + ACE_NOTREACHED (break); + } + return 0; +} + TAO_POA * TAO_Default_Resource_Factory::get_root_poa (void) { @@ -578,11 +405,18 @@ TAO_Default_Resource_Factory::create_input_cdr_data_block (size_t size) return 0; } +TAO_GLOBAL_Collocation_Table * +TAO_Default_Resource_Factory::get_global_collocation_table (void) +{ + return (collocation_table_source_ == TAO_GLOBAL ? GLOBAL_Collocation_Table::instance () : 0); +} + // **************************************************************** TAO_Allocated_Resources::TAO_Allocated_Resources (void) : r_ (0), object_adapter_ (0), + cached_connect_strategy_ (0), poa_(0), input_cdr_dblock_allocator_ (0), input_cdr_buffer_allocator_ (0), @@ -611,13 +445,52 @@ TAO_Allocated_Resources::~TAO_Allocated_Resources (void) this->output_cdr_buffer_allocator_->remove (); delete this->output_cdr_buffer_allocator_; + if (this->cached_connect_strategy_ != 0) + { + // Zap the creation strategy that we created earlier + delete this->cached_connect_strategy_->creation_strategy (); + delete this->cached_connect_strategy_; + } + delete this->object_adapter_; + this->c_.close (); + delete this->r_; } // **************************************************************** +TAO_Default_Reactor::TAO_Default_Reactor (int nolock) + : ACE_Reactor ((nolock ? + (ACE_Reactor_Impl*) new TAO_NULL_LOCK_REACTOR : + (ACE_Reactor_Impl*) new TAO_REACTOR), + 1) +{ +} + +TAO_Default_Reactor::~TAO_Default_Reactor (void) +{ +} + +// **************************************************************** + +TAO_Collocation_Table_Lock::TAO_Collocation_Table_Lock (void) +{ + this->lock_ = TAO_ORB_Core_instance ()->server_factory ()->create_collocation_table_lock (); + // We don't need to worry about the race condition here because this + // is called from within the ctor of Hash_Map_Manager which is + // placed inside a ACE_Singleton. +} + +TAO_Collocation_Table_Lock::~TAO_Collocation_Table_Lock (void) +{ + delete this->lock_; + this->lock_ = 0; +} + +// **************************************************************** + TAO_Cached_Connector_Lock::TAO_Cached_Connector_Lock (void) { this->lock_ = TAO_ORB_Core_instance ()->server_factory ()->create_cached_connector_lock (); @@ -647,6 +520,18 @@ template class ACE_Malloc<ACE_LOCAL_MEMORY_POOL,ACE_SYNCH_MUTEX>; template class ACE_Allocator_Adapter<ACE_Malloc<ACE_LOCAL_MEMORY_POOL,ACE_SYNCH_MUTEX> >; template class ACE_Locked_Data_Block<ACE_Lock_Adapter<ACE_SYNCH_MUTEX> >; +template class ACE_Strategy_Acceptor<TAO_Server_Connection_Handler, TAO_SOCK_ACCEPTOR>; +template class ACE_Creation_Strategy<TAO_Client_Connection_Handler>; +template class ACE_Connect_Strategy<TAO_Client_Connection_Handler, TAO_SOCK_CONNECTOR>; +template class ACE_Strategy_Connector<TAO_Client_Connection_Handler, TAO_SOCK_CONNECTOR>; +template class ACE_NOOP_Creation_Strategy<TAO_Client_Connection_Handler>; +template class ACE_Concurrency_Strategy<TAO_Client_Connection_Handler>; +template class ACE_NOOP_Concurrency_Strategy<TAO_Client_Connection_Handler>; +template class ACE_Recycling_Strategy<TAO_Client_Connection_Handler>; +template class ACE_Connector<TAO_Client_Connection_Handler, TAO_SOCK_CONNECTOR>; + +template class ACE_Node<TAO_Client_Connection_Handler *>; + template class ACE_Singleton<TAO_Allocated_Resources, ACE_SYNCH_MUTEX>; template class ACE_TSS_Singleton<TAO_Allocated_Resources, ACE_SYNCH_MUTEX>; template class ACE_TSS<TAO_Allocated_Resources>; @@ -661,6 +546,18 @@ template class ACE_Select_Reactor_T< ACE_Select_Reactor_Token_T<ACE_Noop_Token> #pragma instantiate ACE_Allocator_Adapter<ACE_Malloc<ACE_LOCAL_MEMORY_POOL,ACE_SYNCH_MUTEX> > #pragma instantiate ACE_Locked_Data_Block<ACE_Lock_Adapter<ACE_SYNCH_MUTEX> > +#pragma instantiate ACE_Strategy_Acceptor<TAO_Server_Connection_Handler, TAO_SOCK_ACCEPTOR> +#pragma instantiate ACE_Creation_Strategy<TAO_Client_Connection_Handler> +#pragma instantiate ACE_Connect_Strategy<TAO_Client_Connection_Handler, TAO_SOCK_CONNECTOR> +#pragma instantiate ACE_Strategy_Connector<TAO_Client_Connection_Handler, TAO_SOCK_CONNECTOR> +#pragma instantiate ACE_NOOP_Creation_Strategy<TAO_Client_Connection_Handler> +#pragma instantiate ACE_Concurrency_Strategy<TAO_Client_Connection_Handler> +#pragma instantiate ACE_NOOP_Concurrency_Strategy<TAO_Client_Connection_Handler> +#pragma instantiate ACE_Recycling_Strategy<TAO_Client_Connection_Handler> +#pragma instantiate ACE_Connector<TAO_Client_Connection_Handler, TAO_SOCK_CONNECTOR> + +#pragma instantiate ACE_Node<TAO_Client_Connection_Handler *> + #pragma instantiate ACE_Singleton<TAO_Allocated_Resources, ACE_SYNCH_MUTEX> #pragma instantiate ACE_TSS_Singleton<TAO_Allocated_Resources, ACE_SYNCH_MUTEX> #pragma instantiate ACE_TSS<TAO_Allocated_Resources> |