From 6faa9e904239f207711fcf16040827bfb654ebdf Mon Sep 17 00:00:00 2001 From: coryan Date: Mon, 7 May 2001 22:16:35 +0000 Subject: ChangeLogTag:Mon May 7 14:54:48 2001 Carlos O'Ryan --- TAO/ChangeLogs/ChangeLog-02a | 28 ++++++++++++++----- TAO/tao/Stub.cpp | 16 +++++------ TAO/tao/Stub.h | 66 ++++++++++++++++++++++++++++---------------- TAO/tao/Stub.i | 3 +- 4 files changed, 71 insertions(+), 42 deletions(-) diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a index b7f8214d85e..1519ae8c239 100644 --- a/TAO/ChangeLogs/ChangeLog-02a +++ b/TAO/ChangeLogs/ChangeLog-02a @@ -1,12 +1,26 @@ +Mon May 7 14:54:48 2001 Carlos O'Ryan + + * tao/Stub.h: + * tao/Stub.i: + * tao/Stub.cpp: + Bug 542 (http://ace.cs.wustl.edu/bugzilla/show_bug.cgi?id=542) + has reared its ugly head once again. + However, I think I finally nailed it: the ORB_Core was reference + counted by each object reference (via TAO_Stub), but the + reference count was descremented in the TAO_Stub destructor + *before* the TAO_Profiles were destroyed. + This also fixes the crashes in Big_Oneways and Big_Twoways + tests. + Mon May 07 10:47:11 2001 Carlos O'Ryan - * tao/GIOP_Message_Base.cpp (write_protocol_header): - Optimize the implementation of this function. Insted of - marshaling each field of the GIOP header individually we create - one big octet array, store all the fields there (they are octets - for the most part) and then marshal the whole header in a single - operation. Saves a little over 0.5% on the client and server - sides. + * tao/GIOP_Message_Base.cpp (write_protocol_header): + Optimize the implementation of this function. Insted of + marshaling each field of the GIOP header individually we create + one big octet array, store all the fields there (they are octets + for the most part) and then marshal the whole header in a single + operation. Saves a little over 0.5% on the client and server + sides. Mon May 07 10:35:27 2001 Carlos O'Ryan diff --git a/TAO/tao/Stub.cpp b/TAO/tao/Stub.cpp index af0ecc4eebd..1a4294b11da 100644 --- a/TAO/tao/Stub.cpp +++ b/TAO/tao/Stub.cpp @@ -40,6 +40,9 @@ TAO_Stub::TAO_Stub (const char *repository_id, const TAO_MProfile &profiles, TAO_ORB_Core *orb_core) : type_id (repository_id), + orb_core_ (orb_core), + orb_ (), + servant_orb_ (), #if (TAO_HAS_RT_CORBA == 1) priority_model_policy_ (0), priority_banded_connection_policy_ (0), @@ -53,9 +56,6 @@ TAO_Stub::TAO_Stub (const char *repository_id, profile_success_ (0), refcount_lock_ (), refcount_ (1), - orb_core_ (orb_core), - orb_ (), - servant_orb_ (), #if (TAO_HAS_CORBA_MESSAGING == 1) policies_ (0), #endif /* TAO_HAS_CORBA_MESSAGING == 1 */ @@ -63,7 +63,7 @@ TAO_Stub::TAO_Stub (const char *repository_id, ior_info_ (0), forwarded_ior_info_ (0) { - if (this->orb_core_ == 0) + if (this->orb_core_.get() == 0) { if (TAO_debug_level > 0) { @@ -71,7 +71,7 @@ TAO_Stub::TAO_Stub (const char *repository_id, ACE_TEXT ("TAO: (%P|%t) TAO_Stub created with default ") ACE_TEXT ("ORB core\n"))); } - this->orb_core_ = TAO_ORB_Core_instance (); + this->orb_core_.reset (TAO_ORB_Core_instance ()); } // Duplicate the ORB_Core, otherwise the allocators and other @@ -129,8 +129,6 @@ TAO_Stub::~TAO_Stub (void) #endif /* TAO_HAS_CORBA_MESSAGING == 1 */ - this->orb_core_->_decr_refcnt (); - if (this->ior_info_) delete this->ior_info_; @@ -715,7 +713,7 @@ TAO_Stub::set_policy_overrides (const CORBA::PolicyList & policies, TAO_Stub* stub; ACE_NEW_RETURN (stub, TAO_Stub (this->type_id.in (), this->base_profiles_, - this->orb_core_), + this->orb_core_.get ()), 0); stub->policies_ = policy_manager.release (); @@ -743,7 +741,7 @@ TAO_Stub::validate_connection (CORBA::PolicyList_out inconsistent_policies, // Use Locate Request to establish connection/make sure the object // is there ... TAO_GIOP_Locate_Request_Invocation locate_request (this, - this->orb_core_); + this->orb_core_.get ()); locate_request.init_inconsistent_policies (ACE_TRY_ENV); ACE_CHECK_RETURN (0); diff --git a/TAO/tao/Stub.h b/TAO/tao/Stub.h index b969ea38761..3c67bef1142 100644 --- a/TAO/tao/Stub.h +++ b/TAO/tao/Stub.h @@ -380,9 +380,41 @@ private: CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)); -#if (TAO_HAS_RT_CORBA == 1) private: + /// Automatically manage the ORB_Core reference count + /** + * The ORB_Core cannot go away until the object references it + * creates are destroyed. There are multiple reasons for this, but + * in particular, the allocators used for some of the TAO_Profile + * objects contained on each TAO_Stub are owned by the TAO_ORB_Core. + * + * This must be the first field of the class, otherwise the + * TAO_ORB_Core is destroyed too early! + * + */ + TAO_ORB_Core_Auto_Ptr orb_core_; + + /// ORB required for reference counting. This will help us keep the + /// ORB around until the CORBA::Object we represent dies. + /** + * @todo Why do we need both a reference to the ORB_Core and its + * ORB? It think the memory management rules for the ORB_Core + * changed, in the good old days it was the CORBA::ORB class + * who owned the ORB_Core, now it is the other way around.... + */ + CORBA::ORB_var orb_; + + /** + * If this stub refers to a collocated object then we need to hold on to + * the servant's ORB (which may be different from the client ORB) so that, + * 1. we know that the ORB will stay alive long enough, and, + * 2. we can search for the servant/POA's status starting from + * the ORB's RootPOA. + */ + CORBA::ORB_var servant_orb_; + +#if (TAO_HAS_RT_CORBA == 1) /// Helper method used to parse the policies. void parse_policies (CORBA::Environment &ACE_TRY_ENV); @@ -393,12 +425,13 @@ private: void exposed_client_protocol (CORBA::Policy_ptr policy); -private: - - // The following attribute are used to cache - // the different kind of policies and avoid to - // parse the MProfile's policy list each time we - // are asked about a given policy. + /** @name Cache RT-CORBA policies + * + * The following attribute are used to cache the different kind of + * policies and avoid to parse the MProfile's policy list each time + * we are asked about a given policy. + */ + //@{ CORBA::Policy *priority_model_policy_; @@ -408,8 +441,9 @@ private: CORBA::Boolean are_policies_parsed_; + //@} + #endif /* TAO_HAS_RT_CORBA == 1 */ -private: /// Ordered list of profiles for this object. TAO_MProfile base_profiles_; @@ -433,22 +467,6 @@ private: /// Number of outstanding references to this object. CORBA::ULong refcount_; - /// The ORB. - TAO_ORB_Core* orb_core_; - - /// ORB required for reference counting. This will help us keep the - /// ORB around until the CORBA::Object we represent dies. - CORBA::ORB_var orb_; - - /** - * If this stub refers to a collocated object then we need to hold on to - * the servant's ORB (which may be different from the client ORB) so that, - * 1. we know that the ORB will stay alive long enough, and, - * 2. we can search for the servant/POA's status starting from - * the ORB's RootPOA. - */ - CORBA::ORB_var servant_orb_; - /// The policy overrides in this object, if nil then use the default /// policies. TAO_Policy_Manager_Impl *policies_; diff --git a/TAO/tao/Stub.i b/TAO/tao/Stub.i index 02c950c6e5e..ab725253610 100644 --- a/TAO/tao/Stub.i +++ b/TAO/tao/Stub.i @@ -247,11 +247,10 @@ TAO_Stub::forward_profiles (void) const return this->forward_profiles_; } - ACE_INLINE TAO_ORB_Core* TAO_Stub::orb_core (void) const { - return this->orb_core_; + return this->orb_core_.get (); } ACE_INLINE CORBA::ORB_var & -- cgit v1.2.1