diff options
-rw-r--r-- | TAO/ChangeLog-99c | 18 | ||||
-rw-r--r-- | TAO/tao/ORB.cpp | 302 | ||||
-rw-r--r-- | TAO/tao/ORB.h | 113 | ||||
-rw-r--r-- | TAO/tao/ORB.i | 6 | ||||
-rw-r--r-- | TAO/tao/ORB_Core.cpp | 73 | ||||
-rw-r--r-- | TAO/tao/ORB_Core.h | 19 |
6 files changed, 245 insertions, 286 deletions
diff --git a/TAO/ChangeLog-99c b/TAO/ChangeLog-99c index ddb182ef5ec..7c2fdbdeb30 100644 --- a/TAO/ChangeLog-99c +++ b/TAO/ChangeLog-99c @@ -1,3 +1,21 @@ +Wed Aug 25 22:31:34 1999 Carlos O'Ryan <coryan@cs.wustl.edu> + + * tao/ORB.h: + * tao/ORB.i: + * tao/ORB.cpp: + Eliminated cached references to the Naming, Trading and ImplRepo + because otherwise doing resolve_initial_references() after the + server restarts does not return the new IOR. + Also removed the place holders for the scheduling and event + services that were not used at all and now can be replaced by + the -ORBInitRef option. + + * tao/ORB_Core.h: + * tao/ORB_Core.cpp: + Moved the open() and create_stub_object() methods from the ORB + class to the ORB_Core class, this is their natural location and + eliminate cross calls between them. + Wed Aug 25 18:18:04 1999 Carlos O'Ryan <coryan@cs.wustl.edu> * orbsvcs/orbsvcs/AV/Endpoint_Strategy.cpp: diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp index 5d3b4c02ec4..584ca99ee7e 100644 --- a/TAO/tao/ORB.cpp +++ b/TAO/tao/ORB.cpp @@ -146,12 +146,6 @@ CORBA::Exception *CORBA::ORB::InvalidName::_alloc (void) CORBA_ORB::CORBA_ORB (TAO_ORB_Core *orb_core) : refcount_ (1), - open_called_ (0), - name_service_ (CORBA_Object::_nil ()), - schedule_service_ (CORBA_Object::_nil ()), - event_service_ (CORBA_Object::_nil ()), - trading_service_ (CORBA_Object::_nil ()), - implrepo_service_ (CORBA_Object::_nil ()), orb_core_ (orb_core), # ifdef TAO_HAS_VALUETYPE valuetype_factory_map_ (0), @@ -162,17 +156,6 @@ CORBA_ORB::CORBA_ORB (TAO_ORB_Core *orb_core) CORBA_ORB::~CORBA_ORB (void) { - if (!CORBA::is_nil (this->name_service_)) - CORBA::release (this->name_service_); - if (!CORBA::is_nil (this->schedule_service_)) - CORBA::release (this->schedule_service_); - if (!CORBA::is_nil (this->event_service_)) - CORBA::release (this->event_service_); - if (!CORBA::is_nil (this->trading_service_)) - CORBA::release (this->trading_service_); - if (!CORBA::is_nil (this->implrepo_service_)) - CORBA::release (this->implrepo_service_); - this->orb_core_->fini (); ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, tao_mon, *ACE_Static_Object_Lock::instance ())); @@ -194,35 +177,6 @@ CORBA_ORB::~CORBA_ORB (void) # endif /* TAO_HAS_VALUETYPE */ } -// Set up listening endpoints. - -int -CORBA_ORB::open (void) -{ - // Double check pattern - if (this->open_called_ == 1) - return 1; - - ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, tao_mon, this->open_lock_, -1); - - if (this->open_called_ == 1) - return 1; - - TAO_Acceptor_Registry *ar = this->orb_core_->acceptor_registry (); - // get a reference to the acceptor_registry! - - // Initialize all the endpoints ... the registry will use the - // orb_core_ to obtain a list of endpoints and strategies! - - if (ar->open (this->orb_core_) == -1) - // Need to return an error somehow!! Maybe set do_exit? - return -1; - - this->open_called_ = 1; - - return 0; -} - void CORBA_ORB::shutdown (CORBA::Boolean wait_for_completion, CORBA::Environment &ACE_TRY_ENV) @@ -444,61 +398,51 @@ CORBA_ORB::resolve_ior_manipulation (CORBA::Environment& ACE_TRY_ENV) } CORBA_Object_ptr -CORBA_ORB::resolve_service (const char *service_name, - ACE_Time_Value *timeout, - CORBA::Environment& ACE_TRY_ENV) +CORBA_ORB::resolve_name_service (ACE_Time_Value *timeout, + CORBA::Environment& ACE_TRY_ENV) { CORBA_Object_var return_value = CORBA_Object::_nil (); - // First check to see if we've already initialized this. - if (!CORBA::is_nil (this->name_service_)) + ACE_CString name_service_ior = + this->orb_core_->orb_params ()->name_service_ior (); + + // Second, check to see if the user has give us a parameter on + // the command-line. + if (name_service_ior.length () == 0) + // Third, check to see if the user has an environment variable. + name_service_ior = ACE_OS::getenv ("NameServiceIOR"); + + if (name_service_ior.length () != 0) { - return_value = CORBA::Object::_duplicate (this->name_service_); + return_value = + this->string_to_object (name_service_ior.c_str (), + ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA_Object::_nil ()); } else { - ACE_CString name_service_ior = - this->orb_core_->orb_params ()->name_service_ior (); - - // Second, check to see if the user has give us a parameter on - // the command-line. - if (name_service_ior.length () == 0) - // Third, check to see if the user has an environment variable. - name_service_ior = ACE_OS::getenv ("NameServiceIOR"); + // First, determine if the port was supplied on the command line + u_short port = + this->orb_core_->orb_params ()->name_service_port (); - if (name_service_ior.length () != 0) + if (port == 0) { - return_value = - this->string_to_object (name_service_ior.c_str (), - ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA_Object::_nil ()); - } - else - { - // First, determine if the port was supplied on the command line - u_short port = - this->orb_core_->orb_params ()->name_service_port (); + // Look for the port among our environment variables. + const char *port_number = + ACE_OS::getenv ("NameServicePort"); - if (port == 0) - { - // Look for the port among our environment variables. - const char *port_number = - ACE_OS::getenv ("NameServicePort"); - - if (port_number != 0) - port = (u_short) ACE_OS::atoi (port_number); - else - port = TAO_DEFAULT_NAME_SERVER_REQUEST_PORT; - } - - return_value = - this->multicast_to_service (service_name, - port, - timeout, - ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA_Object::_nil ()); + if (port_number != 0) + port = (u_short) ACE_OS::atoi (port_number); + else + port = TAO_DEFAULT_NAME_SERVER_REQUEST_PORT; } - this->name_service_ = CORBA::Object::_duplicate (return_value.ptr ()); + + return_value = + this->multicast_to_service ("NameService", + port, + timeout, + ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA_Object::_nil ()); } // Return ior. @@ -511,58 +455,47 @@ CORBA_ORB::resolve_trading_service (ACE_Time_Value *timeout, { CORBA_Object_var return_value = CORBA_Object::_nil (); - // First check to see if we've already initialized this. - if (this->trading_service_ != CORBA_Object::_nil ()) + ACE_CString trading_service_ior = + this->orb_core_->orb_params ()->trading_service_ior (); + + // Second, check to see if the user has give us a parameter on + // the command-line. + if (trading_service_ior.length () == 0) + // Third, check to see if the user has an environment variable. + trading_service_ior = ACE_OS::getenv ("TradingServiceIOR"); + + if (trading_service_ior.length () != 0) { - // @@ Someone please double-check this ;-) - return_value = this->trading_service_; + return_value = + this->string_to_object (trading_service_ior.c_str (), ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA_Object::_nil ()); } else { - ACE_CString trading_service_ior = - this->orb_core_->orb_params ()->trading_service_ior (); + // First, determine if the port was supplied on the command line + u_short port = + this->orb_core_->orb_params ()->trading_service_port (); - // Second, check to see if the user has give us a parameter on - // the command-line. - if (trading_service_ior.length () == 0) - // Third, check to see if the user has an environment variable. - trading_service_ior = ACE_OS::getenv ("TradingServiceIOR"); - - if (trading_service_ior.length () != 0) + if (port == 0) { - return_value = - this->string_to_object (trading_service_ior.c_str (), ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA_Object::_nil ()); - } - else - { - // First, determine if the port was supplied on the command line - // @@ FRED: need a generic rep for this! - u_short port = - this->orb_core_->orb_params ()->trading_service_port (); + // Look for the port among our environment variables. + const char *port_number = ACE_OS::getenv ("TradingServicePort"); - if (port == 0) - { - // Look for the port among our environment variables. - const char *port_number = ACE_OS::getenv ("TradingServicePort"); - - if (port_number != 0) - port = (u_short) ACE_OS::atoi (port_number); - else - port = TAO_DEFAULT_TRADING_SERVER_REQUEST_PORT; - } - - return_value = - this->multicast_to_service ("TradingService", - port, - timeout, - ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA_Object::_nil ()); + if (port_number != 0) + port = (u_short) ACE_OS::atoi (port_number); + else + port = TAO_DEFAULT_TRADING_SERVER_REQUEST_PORT; } - this->trading_service_ = return_value.ptr (); + + return_value = + this->multicast_to_service ("TradingService", + port, + timeout, + ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA_Object::_nil ()); } - return CORBA_Object::_duplicate (return_value._retn ()); + return return_value._retn (); } CORBA_Object_ptr @@ -571,57 +504,47 @@ CORBA_ORB::resolve_implrepo_service (ACE_Time_Value *timeout, { CORBA_Object_var return_value = CORBA_Object::_nil (); - // First check to see if we've already initialized this. - if (this->implrepo_service_ != CORBA_Object::_nil ()) + ACE_CString implrepo_service_ior = + this->orb_core_->orb_params ()->implrepo_service_ior (); + + // Second, check to see if the user has give us a parameter on + // the command-line. + if (implrepo_service_ior.length () == 0) + // Third, check to see if the user has an environment variable. + implrepo_service_ior = ACE_OS::getenv ("ImplRepoServiceIOR"); + + if (implrepo_service_ior.length () != 0) { - return_value = this->implrepo_service_; + return_value = + this->string_to_object (implrepo_service_ior.c_str (), ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA_Object::_nil ()); } else { - ACE_CString implrepo_service_ior = - this->orb_core_->orb_params ()->implrepo_service_ior (); - - // Second, check to see if the user has give us a parameter on - // the command-line. - if (implrepo_service_ior.length () == 0) - // Third, check to see if the user has an environment variable. - implrepo_service_ior = ACE_OS::getenv ("ImplRepoServiceIOR"); + // First, determine if the port was supplied on the command line + u_short port = + this->orb_core_->orb_params ()->implrepo_service_port (); - if (implrepo_service_ior.length () != 0) + if (port == 0) { - return_value = - this->string_to_object (implrepo_service_ior.c_str (), ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA_Object::_nil ()); - } - else - { - // First, determine if the port was supplied on the command line - // @@ FRED: need a generic rep for this! - u_short port = - this->orb_core_->orb_params ()->implrepo_service_port (); - - if (port == 0) - { - // Look for the port among our environment variables. - const char *port_number = ACE_OS::getenv ("ImplRepoServicePort"); - - if (port_number != 0) - port = (u_short) ACE_OS::atoi (port_number); - else - port = TAO_DEFAULT_IMPLREPO_SERVER_REQUEST_PORT; - } - - return_value = - this->multicast_to_service ("ImplRepoService", - port, - timeout, - ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA_Object::_nil ()); + // Look for the port among our environment variables. + const char *port_number = ACE_OS::getenv ("ImplRepoServicePort"); + + if (port_number != 0) + port = (u_short) ACE_OS::atoi (port_number); + else + port = TAO_DEFAULT_IMPLREPO_SERVER_REQUEST_PORT; } - this->implrepo_service_ = return_value.ptr (); + + return_value = + this->multicast_to_service ("ImplRepoService", + port, + timeout, + ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA_Object::_nil ()); } - return CORBA_Object::_duplicate (return_value._retn ()); + return return_value._retn (); } int @@ -919,7 +842,7 @@ CORBA_ORB::resolve_initial_references (const char *name, // entry.... Try the hard-coded ways to find the basic services... if (ACE_OS::strcmp (name, TAO_OBJID_NAMESERVICE) == 0) - return this->resolve_service ("NameService", timeout, ACE_TRY_ENV); + return this->resolve_name_service (timeout, ACE_TRY_ENV); else if (ACE_OS::strcmp (name, TAO_OBJID_TRADINGSERVICE) == 0) return this->resolve_trading_service (timeout, ACE_TRY_ENV); @@ -946,33 +869,10 @@ CORBA_ORB::create_stub_object (const TAO_ObjectKey &key, const char *type_id, CORBA::Environment &ACE_TRY_ENV) { - if (this->open () == -1) - ACE_THROW_RETURN (CORBA::INTERNAL (), 0); - - CORBA::String id = 0; - - if (type_id) - id = CORBA::string_dup (type_id); - - TAO_Stub *stub = 0; - - size_t pfile_count = - this->orb_core_->acceptor_registry ()->endpoint_count (); - - // First we create a profile list, well actually the empty container - TAO_MProfile mp (pfile_count); - - this->orb_core_->acceptor_registry ()->make_mprofile (key, mp); - - ACE_NEW_THROW_EX (stub, - TAO_Stub (id, mp, this->orb_core_), - CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE, - CORBA::COMPLETED_MAYBE)); - ACE_CHECK_RETURN (stub); - - return stub; + return this->orb_core_->create_stub_object (key, + type_id, + ACE_TRY_ENV); } - // Create an objref CORBA::Object_ptr diff --git a/TAO/tao/ORB.h b/TAO/tao/ORB.h index 38417465cb6..bd568a0c0f2 100644 --- a/TAO/tao/ORB.h +++ b/TAO/tao/ORB.h @@ -346,18 +346,16 @@ public: // Returns a pointer to a nil ORB, i.e., an non-existent ORB. This // can be used for initialization or in comparisons. - virtual CORBA::Object_ptr string_to_object ( - const char *str, - CORBA_Environment &ACE_TRY_ENV = - TAO_default_environment ()); + CORBA::Object_ptr string_to_object (const char *str, + CORBA_Environment &ACE_TRY_ENV = + TAO_default_environment ()); // Turn a string-ified object reference back into an object pointer. // Typically these strings are created using <object_to_string()>, // but not necessarily locally. - virtual CORBA::String object_to_string ( - CORBA::Object_ptr obj, - CORBA_Environment &ACE_TRY_ENV = - TAO_default_environment ()); + CORBA::String object_to_string (CORBA::Object_ptr obj, + CORBA_Environment &ACE_TRY_ENV = + TAO_default_environment ()); // Turn an object reference into a string. Each type of ORB, // e.g. an IIOP ORB, must implement this. This can be used by // servers to publish their whereabouts to clients. The output of @@ -368,15 +366,17 @@ public: #ifdef TAO_HAS_VALUETYPE // Value factory operations (CORBA 2.3 ptc/98-10-05 Ch. 4.2 p.4-7) CORBA::ValueFactory_ptr register_value_factory ( - const char *repository_id, - CORBA::ValueFactory_ptr factory, - CORBA_Environment &ACE_TRY_ENV = - TAO_default_environment () ); + const char *repository_id, + CORBA::ValueFactory_ptr factory, + CORBA_Environment &ACE_TRY_ENV = + TAO_default_environment () ); void unregister_value_factory (const char * repository_id, CORBA_Environment &ACE_TRY_ENV = - TAO_default_environment () ); - CORBA::ValueFactory_ptr lookup_value_factory (const char *repository_id, - CORBA_Environment &ACE_TRY_ENV = TAO_default_environment () ); + TAO_default_environment () ); + CORBA::ValueFactory_ptr lookup_value_factory ( + const char *repository_id, + CORBA_Environment &ACE_TRY_ENV = + TAO_default_environment () ); #endif /* TAO_HAS_VALUETYPE */ #if !defined (TAO_HAS_MINIMUM_CORBA) @@ -392,18 +392,18 @@ public: void create_list (CORBA::Long count, CORBA::NVList_ptr &new_list, CORBA_Environment &ACE_TRY_ENV = - TAO_default_environment ()); + TAO_default_environment ()); // The following are not implemented and just throw // CORBA::NO_IMPLEMENT. void create_named_value (CORBA::NamedValue_ptr &nmval, CORBA_Environment &ACE_TRY_ENV = - TAO_default_environment ()); + TAO_default_environment ()); void create_exception_list (CORBA::ExceptionList_ptr &exclist, CORBA_Environment &ACE_TRY_ENV = - TAO_default_environment ()); + TAO_default_environment ()); void create_context_list (CORBA::ContextList_ptr &ctxtlist, CORBA_Environment &ACE_TRY_ENV = @@ -536,38 +536,40 @@ public: // = TAO-specific extensions to the CORBA specification. // ---------------------------------------------------------------- - virtual TAO_SERVANT_LOCATION _get_collocated_servant (TAO_Stub *p, - TAO_ServantBase *&servant); + TAO_SERVANT_LOCATION _get_collocated_servant (TAO_Stub *p, + TAO_ServantBase *&servant); // Return the object pointer of an collocated object it there is // one, otherwise, return 0. Each type of ORB, e. g., IIOP ORB, // must implement this and determine what is a collocated object // based on information provided in the TAO_Stub. - virtual int _tao_add_to_IOR_table (const ACE_CString &object_id, - CORBA::Object_ptr obj); + int _tao_add_to_IOR_table (const ACE_CString &object_id, + CORBA::Object_ptr obj); // Add a mapping ObjectID->IOR to the table. - virtual int _tao_find_in_IOR_table (const ACE_CString &object_id, - CORBA::Object_ptr &obj); + int _tao_find_in_IOR_table (const ACE_CString &object_id, + CORBA::Object_ptr &obj); // Find the given ObjectID in the table. CORBA_Object_ptr resolve_root_poa (CORBA_Environment &ACE_TRY_ENV, - const char *adapter_name = TAO_DEFAULT_ROOTPOA_NAME, + const char *adapter_name = + TAO_DEFAULT_ROOTPOA_NAME, TAO_POA_Manager *poa_manager = 0, const TAO_POA_Policies *policies = 0); // Resolve the POA. TAO_Stub *create_stub_object (const TAO_ObjectKey &key, const char *type_id, - CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ()); - // Makes sure that the ORB is open and then creates an IIOP object - // based on the endpoint. + CORBA_Environment &ACE_TRY_ENV = + TAO_default_environment ()); + // Delegates on the ORB_Core to create a TAO_Stub. CORBA_Object_ptr key_to_object (const TAO_ObjectKey &key, const char *type_id, TAO_ServantBase *servant = 0, CORBA::Boolean collocated = 1, - CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ()); + CORBA_Environment &ACE_TRY_ENV = + TAO_default_environment ()); // Convert key into an object reference. Return Object_ptr as out // parameter. Errors will come through the environment. // @@ -590,26 +592,18 @@ public: // ORB will not normally return OBJECT_NOT_EXIST unless the POA // reports that fault. - int open (void); - // Set up the ORB Core's acceptor to listen on the - // previously-specified port for requests. Returns -1 on failure, - // else 0. - - static void init_orb_globals (CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ()); + static void init_orb_globals (CORBA_Environment &ACE_TRY_ENV = + TAO_default_environment ()); // Initialize the ORB globals correctly, i.e., only when they // haven't been initialized yet. - static CORBA::Boolean orb_free_resources (void); - // Indicates if we have reached a point where all ORB owned - // resources will be deallocated. - // The function used by tao to handle the "unexpected" exceptions, // It raises CORBA::UNKNOWN. static void _tao_unexpected_exception (void); // Reference counting... - virtual CORBA::ULong _incr_refcnt (void); - virtual CORBA::ULong _decr_refcnt (void); + CORBA::ULong _incr_refcnt (void); + CORBA::ULong _decr_refcnt (void); void _use_omg_ior_format (CORBA::Boolean ior); // Set the IOR flag. @@ -633,7 +627,7 @@ public: protected: // We must be created via the <ORB_init> call. CORBA_ORB (TAO_ORB_Core *orb_core); - virtual ~CORBA_ORB (void); + ~CORBA_ORB (void); TAO_SERVANT_LOCATION _find_collocated_servant (TAO_Stub *sobj, TAO_ORB_Core *orb_core, @@ -658,11 +652,10 @@ protected: private: - CORBA_Object_ptr resolve_service (const char* service_name, - ACE_Time_Value *timeout, - CORBA::Environment& ACE_TRY_ENV); - // Resolve the service name. - + CORBA_Object_ptr resolve_name_service (ACE_Time_Value *timeout, + CORBA::Environment& ACE_TRY_ENV); + // Resolve the name service + CORBA_Object_ptr resolve_trading_service (ACE_Time_Value *timeout, CORBA::Environment& ACE_TRY_ENV); // Resolve the trading object reference. @@ -706,32 +699,6 @@ private: // Maintains a reference count of number of instantiations of the // ORB. - u_int open_called_; - // Flag which denotes that the open method was called. - - ACE_SYNCH_MUTEX open_lock_; - // Mutual exclusion for calling open. - - CORBA_Object_ptr name_service_; - // If this is non-_nil(), then this is the object reference to our - // configured Naming Context. - - CORBA_Object_ptr schedule_service_; - // If this is non-_nil(), then this is the object reference to our - // configured RtecScheduler::Scheduler. - - CORBA_Object_ptr event_service_; - // If this is non-_nil(), then this is the object reference to our - // configured Event Channel. - - CORBA_Object_ptr trading_service_; - // If this is non-_nil(), then this is the object reference to our - // configured Trading. - - CORBA_Object_ptr implrepo_service_; - // If this is non-_nil(), then this is the object reference to our - // configured Implementation Repository. - static int orb_init_count_; // Count of the number of times that <ORB_init> has been called. // This must be protected by <ACE_Static_Object_Lock>. diff --git a/TAO/tao/ORB.i b/TAO/tao/ORB.i index 27bf4fc602a..731127bda42 100644 --- a/TAO/tao/ORB.i +++ b/TAO/tao/ORB.i @@ -291,12 +291,6 @@ CORBA_ORB::_nil (void) return 0; } -ACE_INLINE CORBA::Boolean -CORBA_ORB::orb_free_resources (void) -{ - return !CORBA_ORB::orb_init_count_; -} - ACE_INLINE void CORBA_ORB::_use_omg_ior_format (CORBA::Boolean ior) { diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index 0b1ff71b87f..8bf02c801ce 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -12,10 +12,8 @@ #include "tao/default_resource.h" #include "tao/debug.h" #include "tao/IOR_LookupTable.h" - -#if !defined (__ACE_INLINE__) -# include "tao/ORB_Core.i" -#endif /* ! __ACE_INLINE__ */ +#include "tao/MProfile.h" +#include "tao/Stub.h" #include "tao/Connector_Registry.h" #include "tao/Acceptor_Registry.h" @@ -32,6 +30,10 @@ #include "ace/Codeset_IBM1047.h" #endif /* ACE_MVS */ +#if !defined (__ACE_INLINE__) +# include "tao/ORB_Core.i" +#endif /* ! __ACE_INLINE__ */ + ACE_RCSID(tao, ORB_Core, "$Id$") // **************************************************************** @@ -76,7 +78,8 @@ TAO_ORB_Core::TAO_ORB_Core (const char *orbid) use_tss_resources_ (0), leader_follower_ (this), has_shutdown_ (0), - thread_per_connection_use_timeout_ (1) + thread_per_connection_use_timeout_ (1), + open_called_ (0) { ACE_NEW (this->poa_current_, TAO_POA_Current); @@ -1365,6 +1368,38 @@ TAO_ORB_Core::leader_follower_condition_variable (void) return tss->leader_follower_condition_variable_; } +TAO_Stub * +TAO_ORB_Core::create_stub_object (const TAO_ObjectKey &key, + const char *type_id, + CORBA::Environment &ACE_TRY_ENV) +{ + if (this->open () == -1) + ACE_THROW_RETURN (CORBA::INTERNAL (), 0); + + CORBA::String id = 0; + + if (type_id) + id = CORBA::string_dup (type_id); + + TAO_Stub *stub = 0; + + size_t pfile_count = + this->acceptor_registry ()->endpoint_count (); + + // First we create a profile list, well actually the empty container + TAO_MProfile mp (pfile_count); + + this->acceptor_registry ()->make_mprofile (key, mp); + + ACE_NEW_THROW_EX (stub, + TAO_Stub (id, mp, this), + CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE, + CORBA::COMPLETED_MAYBE)); + ACE_CHECK_RETURN (stub); + + return stub; +} + int TAO_ORB_Core::is_collocated (const TAO_MProfile& mprofile) { @@ -1413,7 +1448,7 @@ TAO_ORB_Core::run (ACE_Time_Value *tv, int break_on_timeouts) // This method should only be called by servers, so now we set up // for listening! - if (this->orb ()->open () == -1) + if (this->open () == -1) return -1; int result = 1; @@ -1529,6 +1564,32 @@ TAO_ORB_Core::shutdown (CORBA::Boolean wait_for_completion, tm->wait (); } +// Set up listening endpoints. + +int +TAO_ORB_Core::open (void) +{ + // Double check pattern + if (this->open_called_ == 1) + return 1; + + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, tao_mon, this->open_lock_, -1); + + if (this->open_called_ == 1) + return 1; + + TAO_Acceptor_Registry *ar = this->acceptor_registry (); + // get a reference to the acceptor_registry! + + if (ar->open (this) == -1) + // Need to return an error somehow!! Maybe set do_exit? + return -1; + + this->open_called_ = 1; + + return 0; +} + // **************************************************************** ACE_SYNCH_CONDITION* diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h index e6baea7a3ff..d48dc56b0bb 100644 --- a/TAO/tao/ORB_Core.h +++ b/TAO/tao/ORB_Core.h @@ -438,6 +438,13 @@ public: // Condition variable used in the Leader Follower Wait Strategy, on // which the follower thread blocks. + TAO_Stub *create_stub_object (const TAO_ObjectKey &key, + const char *type_id, + CORBA_Environment &ACE_TRY_ENV = + TAO_default_environment ()); + // Makes sure that the ORB is open and then creates a TAO_Stub + // based on the endpoint. + protected: int set_iiop_endpoint (int dotted_decimal_addresses, CORBA::UShort port, @@ -467,6 +474,11 @@ protected: // pre-fetched TSS resources, this minimizes the number of calls to // them. + int open (void); + // Set up the ORB Core's acceptor to listen on the + // previously-specified port for requests. Returns -1 on failure, + // else 0. + protected: ACE_SYNCH_MUTEX lock_; // Synchronize internal state... @@ -595,6 +607,13 @@ protected: int thread_per_connection_use_timeout_; ACE_Time_Value thread_per_connection_timeout_; // The value of the timeout if the flag above is not zero + + ACE_SYNCH_MUTEX open_lock_; + // Mutual exclusion for calling open. + + int open_called_; + // Flag which denotes that the open method was called. + }; // **************************************************************** |