diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-05-12 16:13:38 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-05-12 16:13:38 +0000 |
commit | 49c1b7e5025c95ee641163330b34d8bd94d50022 (patch) | |
tree | 9ea8ce3e5b34edcaf8ec639e3fb2b1244a32e4a6 /TAO/tao | |
parent | 2fe713022754c7550170243856faacdfb3c8bf6b (diff) | |
download | ATCD-49c1b7e5025c95ee641163330b34d8bd94d50022.tar.gz |
ChangeLogTag:Wed May 12 10:38:03 1999 Carlos O'Ryan <coryan@cs.wustl.edu>
Diffstat (limited to 'TAO/tao')
-rw-r--r-- | TAO/tao/IIOP_Profile.cpp | 66 | ||||
-rw-r--r-- | TAO/tao/IIOP_Profile.h | 14 | ||||
-rw-r--r-- | TAO/tao/IIOP_Profile.i | 6 | ||||
-rw-r--r-- | TAO/tao/Invocation.cpp | 2 | ||||
-rw-r--r-- | TAO/tao/MProfile.cpp | 159 | ||||
-rw-r--r-- | TAO/tao/MProfile.h | 28 | ||||
-rw-r--r-- | TAO/tao/MProfile.i | 78 | ||||
-rw-r--r-- | TAO/tao/ORB.cpp | 17 | ||||
-rw-r--r-- | TAO/tao/Object.cpp | 26 | ||||
-rw-r--r-- | TAO/tao/Pluggable.cpp | 6 | ||||
-rw-r--r-- | TAO/tao/Pluggable.h | 33 | ||||
-rw-r--r-- | TAO/tao/Pluggable.i | 25 | ||||
-rw-r--r-- | TAO/tao/Stub.cpp | 112 | ||||
-rw-r--r-- | TAO/tao/Stub.h | 20 | ||||
-rw-r--r-- | TAO/tao/Stub.i | 36 | ||||
-rw-r--r-- | TAO/tao/UIOP_Profile.cpp | 66 | ||||
-rw-r--r-- | TAO/tao/UIOP_Profile.h | 11 | ||||
-rw-r--r-- | TAO/tao/UIOP_Profile.i | 7 |
18 files changed, 270 insertions, 442 deletions
diff --git a/TAO/tao/IIOP_Profile.cpp b/TAO/tao/IIOP_Profile.cpp index 434ecd1c937..4a767668f92 100644 --- a/TAO/tao/IIOP_Profile.cpp +++ b/TAO/tao/IIOP_Profile.cpp @@ -30,8 +30,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const ACE_INET_Addr& addr, object_addr_ (addr), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { this->set(addr); int l = ACE_OS::strlen (object_key); @@ -54,8 +53,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const ACE_INET_Addr& addr, object_addr_ (addr), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { this->set(addr); this->create_body (); @@ -73,8 +71,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const ACE_INET_Addr& addr, object_addr_ (addr), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { this->set(addr); int l = ACE_OS::strlen (object_key); @@ -98,8 +95,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const ACE_INET_Addr& addr, object_addr_ (addr), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { this->set(addr); this->create_body (); @@ -117,8 +113,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const char* host, object_addr_ (port, host), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { if (host) @@ -144,8 +139,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const char* host, object_addr_ (addr), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { if (host) @@ -171,8 +165,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const char* host, object_addr_ (port, host), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { ACE_UNUSED_ARG (version); @@ -193,8 +186,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const TAO_IIOP_Profile *pfile) object_addr_(pfile->object_addr_), hint_(0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { ACE_NEW (this->host_, @@ -214,8 +206,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const TAO_IIOP_Profile &pfile) object_addr_(pfile.object_addr_), hint_(0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { ACE_NEW (this->host_, @@ -235,8 +226,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const TAO_IOP_Version &version) object_addr_ (), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { } @@ -250,8 +240,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const char *string, CORBA::Environment &env) object_addr_ (), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { parse_string (string, env); } @@ -266,8 +255,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (void) object_addr_ (), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { } @@ -309,12 +297,6 @@ TAO_IIOP_Profile::~TAO_IIOP_Profile (void) delete [] this->host_; this->host_ = 0; - - if (forward_to_) - { - delete forward_to_; - } - } // return codes: @@ -643,30 +625,6 @@ TAO_IIOP_Profile::_decr_refcnt (void) return 0; } - -void -TAO_IIOP_Profile::forward_to (TAO_MProfile *mprofiles) -{ - // we assume ownership of the profile list!! - if (forward_to_) - delete this->forward_to_; - - ACE_NEW (this->forward_to_, - TAO_MProfile (mprofiles)); - -} - -TAO_MProfile * -TAO_IIOP_Profile::forward_to (void) -{ - TAO_MProfile *temp; - - ACE_NEW_RETURN (temp, - TAO_MProfile (this->forward_to_), - 0); - return temp; -} - CORBA::String TAO_IIOP_Profile::to_string (CORBA::Environment &env) { diff --git a/TAO/tao/IIOP_Profile.h b/TAO/tao/IIOP_Profile.h index c0b43377418..3a1081cb597 100644 --- a/TAO/tao/IIOP_Profile.h +++ b/TAO/tao/IIOP_Profile.h @@ -140,12 +140,6 @@ public: TAO_ObjectKey *_key (CORBA::Environment &env); // Return a pointer to the Object Key. - virtual void forward_to (TAO_MProfile *mprofiles); - // Client object will assume ownership for this object!! - - virtual TAO_MProfile *forward_to (void); - // copy of MProfile, user must delete. - CORBA::Boolean is_equivalent (TAO_Profile *other_profile, CORBA::Environment &env); // Return true if this profile is equivalent to other_profile. Two @@ -207,11 +201,6 @@ private: int set (const ACE_INET_Addr &addr); // helper method to set the INET_Addr. - virtual TAO_MProfile *forward_to_i (void); - // reference to the TAO_MProfile which the current profile was - // forwarded to. This object keeps ownership. Note that this - // method is NOT thread-safe, so it must be called with locks held. - void create_body (void); // Does the work for <add_profile>. @@ -248,9 +237,6 @@ private: CORBA::ULong refcount_; // Number of outstanding references to this object. - - TAO_MProfile *forward_to_; - // list of profiles which we should try forwarding on. }; #if defined (__ACE_INLINE__) diff --git a/TAO/tao/IIOP_Profile.i b/TAO/tao/IIOP_Profile.i index 21c5eb77d89..4b14f5bf659 100644 --- a/TAO/tao/IIOP_Profile.i +++ b/TAO/tao/IIOP_Profile.i @@ -79,9 +79,3 @@ TAO_IIOP_Profile::_nil (void) { return (TAO_IIOP_Profile *)0; } - -ACE_INLINE TAO_MProfile * -TAO_IIOP_Profile::forward_to_i (void) -{ - return this->forward_to_; -} diff --git a/TAO/tao/Invocation.cpp b/TAO/tao/Invocation.cpp index 25753edba5a..b103f7aebfb 100644 --- a/TAO/tao/Invocation.cpp +++ b/TAO/tao/Invocation.cpp @@ -451,7 +451,7 @@ TAO_GIOP_Invocation::location_forward (TAO_InputCDR &inp_stream, // New for Multiple profile. Get the MProfile list from the // forwarded object refererence - this->stub_->add_forward_profiles (stubobj->get_profiles ()); + this->stub_->add_forward_profiles (*stubobj->get_profiles ()); // store the new profile list and set the first forwarding profile // note: this has to be and is thread safe. Also get_profiles returns // a pointer to a new MProfile object which we give to our diff --git a/TAO/tao/MProfile.cpp b/TAO/tao/MProfile.cpp index 963f4becb77..777b81ddabb 100644 --- a/TAO/tao/MProfile.cpp +++ b/TAO/tao/MProfile.cpp @@ -10,50 +10,42 @@ ACE_RCSID(tao, MProfile, "$Id$") # include "tao/MProfile.i" #endif /* __ACE_INLINE__ */ -int -TAO_MProfile::set (CORBA::ULong sz) +void +TAO_MProfile::cleanup (void) { - if (sz == 0) + if (this->pfiles_ != 0) { - // Release all of our profiles. + for (TAO_PHandle i = 0; i < this->last_; ++i) + if (this->pfiles_[i]) + this->pfiles_[i]->_decr_refcnt (); + } - for (TAO_PHandle h = 0; - h < this->size_; - h++) - if (this->pfiles_[h]) - { - this->pfiles_[h]->_decr_refcnt (); - this->pfiles_[h] = 0; - } + delete [] this->pfiles_; + this->pfiles_ = 0; - if (this->size_) - delete [] this->pfiles_; - - if (forward_from_) - delete forward_from_; - - pfiles_ = 0; - current_ = 0; - size_ = 0; - last_= 0; - - this->pfiles_ = 0; - this->current_ = 0; - this->size_ = 0; - this->last_= 0; + this->current_ = 0; + this->size_ = 0; + this->last_ = 0; +} +int +TAO_MProfile::set (CORBA::ULong sz) +{ + if (sz == 0) + { + this->cleanup (); return 0; } // See if we already have an existing profile list or if we need to // get ridof what we have. @@ Fred, please be consistent with your // use of this-> as a prefix for data members. - if (size_) + if (this->size_ != 0) { // Release all of our profiles. for (TAO_PHandle h = 0; - h < size_; + h < this->size_; h++) if (this->pfiles_[h]) { @@ -61,10 +53,13 @@ TAO_MProfile::set (CORBA::ULong sz) this->pfiles_[h] = 0; } - // Next see if we can reuse our profile list memory Since + // Next see if we can reuse our profile list memory if (this->size_ != sz) { // we cant reuse memory since the array sized are different! + // @@ Fred: if sz < this->size_ you could avoid this memory + // allocation, you only need another flag to keep the + // "capacity". delete [] this->pfiles_; ACE_NEW_RETURN (this->pfiles_, @@ -77,36 +72,40 @@ TAO_MProfile::set (CORBA::ULong sz) ACE_NEW_RETURN (this->pfiles_, TAO_Profile_ptr [sz], -1); - // this->pfiles_ + this->size_ = sz; + this->last_ = 0; + this->current_ = 0; + +#if 0 + // @@ Fred: this does *not* work, the literal 0 is the null pointer, + // but the bit representation may be something else. ACE_OS::memset (this->pfiles_, 0, sizeof (TAO_Profile_ptr) * sz); - size_ = sz; - this->last_ = 0; - this->current_ = 0; +#else + for (int i = 0; i != this->size_; ++i) + this->pfiles_[i] = 0; +#endif // @@ since we are being reset, get rid of forward references! - if (forward_from_) - delete forward_from_; + // if (forward_from_) + // delete forward_from_; - return size_; + return this->size_; } int -TAO_MProfile::set (TAO_MProfile *mprofile) +TAO_MProfile::set (const TAO_MProfile &mprofile) { // NOTE: We use mprofile->last_ instead of mprofile->size_ to set // this->size_. This is so we can use set () to trim a profile // list!! - if (mprofile == 0) - return this->set ((CORBA::ULong) 0); - - this->set (mprofile->last_); + this->set (mprofile.last_); // set indexes ... - this->last_ = mprofile->last_; + this->last_ = mprofile.last_; // These are set in set (ULong); // this->current_ = 0; @@ -114,17 +113,73 @@ TAO_MProfile::set (TAO_MProfile *mprofile) // Now reference all profiles. - for (TAO_PHandle h = 0; - h < this->size_; - h++) - if (mprofile->pfiles_[h]) - { - this->pfiles_[h] = mprofile->pfiles_[h]; + for (TAO_PHandle h = 0; h < this->size_; h++) + { + this->pfiles_[h] = mprofile.pfiles_[h]; + if (this->pfiles_[h] != 0) this->pfiles_[h]->_incr_refcnt (); - } + } - if (mprofile->forward_from_) - this->forward_from_ = mprofile->forward_from_; + // + // @@ Fred: here was a gross violation of the invariants for this + // class: if the forward_from_ is owned by us (we call delete all + // the time on it) we cannot share it with mprofile. + // + // if (mprofile->forward_from_) + // this->forward_from_ = mprofile->forward_from_; return 1; } + +int +TAO_MProfile::add_profile (TAO_Profile *pfile) +{ + // skip by the used slots + if (last_ == size_) // full! + return -1; + + pfiles_[last_++] = pfile; + + if (pfile && pfile->_incr_refcnt () == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "(%P|%t) Unable to increment reference count in add_profile!\n"), + -1); + return last_ - 1; +} + +CORBA::Boolean +TAO_MProfile::is_equivalent (TAO_MProfile *first, + TAO_MProfile *second, + CORBA::Environment &env) +{ + // Two profile lists are equivalent iff at least one of the profiles + // form the first list is_equivalent to at least one of the profiles + // from the second list!! + TAO_Profile_ptr *pfiles1 = first->pfiles (); + TAO_Profile_ptr *pfiles2 = second->pfiles (); + TAO_PHandle first_cnt = first->profile_count (); + TAO_PHandle second_cnt = second->profile_count (); + + for (TAO_PHandle h1 = 0; h1 < first_cnt;h1++) + for (TAO_PHandle h2 = 0; h2 < second_cnt; h2++ ) + if (pfiles1[h1]->is_equivalent (pfiles2[h2], env)) + return 1; + + return 0; +} + +CORBA::ULong +TAO_MProfile::hash (CORBA::ULong max, CORBA::Environment &env) +{ + CORBA::ULong hashval = 0; + + if (last_ == 0) + return 0; + + for (TAO_PHandle h=0; h < last_ ; h++) + hashval += pfiles_[h]->hash (max, env); + + // The above hash function return an ULong between 0 and max here we + // simply take the average value and round. + return hashval / last_; +} diff --git a/TAO/tao/MProfile.h b/TAO/tao/MProfile.h index 2248e27cc04..e5958d4310b 100644 --- a/TAO/tao/MProfile.h +++ b/TAO/tao/MProfile.h @@ -21,8 +21,11 @@ #define TAO_MPROFILE_H #include "tao/corbafwd.h" +#include "tao/Pluggable.h" -class TAO_Profile; +// @@ Fred, this definitions are of very little use, can you make them +// local to the Profile class so we don't pollute the global +// namespace typedef TAO_Profile *TAO_Profile_ptr; typedef CORBA::ULong TAO_PHandle; @@ -44,17 +47,24 @@ public: // = Initalization and termination methods. TAO_MProfile (CORBA::ULong sz); - TAO_MProfile (TAO_MProfile *mprofiles); + TAO_MProfile (const TAO_MProfile &mprofiles); // **NOTE: IF mprofiles->last_ > 0, THEN this->size_ will be set to // mprofiles->last_. Otherwise this->size_ - mprofiles->size_. // Furthermore, current_ is set back to 0! i.e. rewound. // The reference count on any profiles in mprofiles is increment // when their references (i.e. pointers) are copied. + TAO_MProfile& operator= (const TAO_MProfile& mprofiles); + // Assigment operator. + + ~TAO_MProfile (void); + // Destructor: decrements reference count on all references + // profiles! + int set (CORBA::ULong sz); // @@ Fred, what does this method do? - int set (TAO_MProfile *mprofile); + int set (const TAO_MProfile &mprofile); // Inits this to the values of mprofile. NOTE: We use // mprofile->last_ instead of mprofile->size_ to set this->size_. // This is so we can use set () to trim a profile list!! @@ -119,15 +129,16 @@ public: CORBA::Environment &env); // @@ FRED: The list should be locked for this! - ~TAO_MProfile (void); - // Deletes this object and decrements reference count on all - // references profiles! - protected: TAO_Profile_ptr *pfiles (void) const; // return the complete list of profiles, this object retains // ownership! + +private: + void cleanup (void); + // Helper method to implement the destructor + private: TAO_MProfile *forward_from_; @@ -155,5 +166,4 @@ private: # include "tao/MProfile.i" #endif /* __ACE_INLINE__ */ -// @@ Fred, please don't use #endif // ..., instead, always use #endif /* ... */ -#endif // TAO_MPROFILE_H +#endif /* TAO_MPROFILE_H */ diff --git a/TAO/tao/MProfile.i b/TAO/tao/MProfile.i index 2f6c3d36c4f..50b164f78d3 100644 --- a/TAO/tao/MProfile.i +++ b/TAO/tao/MProfile.i @@ -1,9 +1,6 @@ // This may look like C, but it's really -*- C++ -*- // $Id$ -#include "tao/MProfile.h" -#include "tao/Pluggable.h" - ACE_INLINE TAO_MProfile::TAO_MProfile (CORBA::ULong sz) : forward_from_(0), @@ -16,7 +13,7 @@ TAO_MProfile::TAO_MProfile (CORBA::ULong sz) } ACE_INLINE -TAO_MProfile::TAO_MProfile (TAO_MProfile *mprofiles) +TAO_MProfile::TAO_MProfile (const TAO_MProfile &mprofiles) : forward_from_(0), pfiles_ (0), current_ (0), @@ -26,17 +23,19 @@ TAO_MProfile::TAO_MProfile (TAO_MProfile *mprofiles) this->set (mprofiles); } -ACE_INLINE -TAO_MProfile::~TAO_MProfile (void) - { - if (this->pfiles_) - for (TAO_PHandle h = 0; h < last_; h++) - if (this->pfiles_[h]) - this->pfiles_[h]->_decr_refcnt (); +ACE_INLINE TAO_MProfile& +TAO_MProfile::operator= (const TAO_MProfile& rhs) +{ + if (this == &rhs) + return *this; - delete [] pfiles_; - pfiles_ = 0; + this->set (rhs); +} +ACE_INLINE +TAO_MProfile::~TAO_MProfile (void) +{ + this->cleanup (); } // Cyclic get next. It will simply cycle through the complete list. @@ -132,22 +131,6 @@ TAO_MProfile::rewind (void) } ACE_INLINE int -TAO_MProfile::add_profile (TAO_Profile *pfile) -{ - // skip by the used slots - if (last_ == size_) // full! - return -1; - - pfiles_[last_++] = pfile; - - if (pfile && pfile->_incr_refcnt () == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "(%P|%t) Unable to increment reference count in add_profile!\n"), - -1); - return last_ - 1; -} - -ACE_INLINE int TAO_MProfile::give_profile (TAO_Profile *pfile) { // skip by the used slots @@ -192,40 +175,3 @@ TAO_MProfile::pfiles (void) const { return this->pfiles_; } - -ACE_INLINE CORBA::Boolean -TAO_MProfile::is_equivalent (TAO_MProfile *first, - TAO_MProfile *second, - CORBA::Environment &env) -{ - // Two profile lists are equivalent iff at least one of the profiles - // form the first list is_equivalent to at least one of the profiles - // from the second list!! - TAO_Profile_ptr *pfiles1 = first->pfiles (); - TAO_Profile_ptr *pfiles2 = second->pfiles (); - TAO_PHandle first_cnt = first->profile_count (); - TAO_PHandle second_cnt = second->profile_count (); - - for (TAO_PHandle h1 = 0; h1 < first_cnt;h1++) - for (TAO_PHandle h2 = 0; h2 < second_cnt; h2++ ) - if (pfiles1[h1]->is_equivalent (pfiles2[h2], env)) - return 1; - - return 0; -} - -ACE_INLINE CORBA::ULong -TAO_MProfile::hash (CORBA::ULong max, CORBA::Environment &env) -{ - CORBA::ULong hashval = 0; - - if (last_ == 0) - return 0; - - for (TAO_PHandle h=0; h < last_ ; h++) - hashval += pfiles_[h]->hash (max, env); - - // The above hash function return an ULong between 0 and max here we - // simply take the average value and round. - return hashval / last_; -} diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp index 03cc0abaee4..20983a4ae45 100644 --- a/TAO/tao/ORB.cpp +++ b/TAO/tao/ORB.cpp @@ -978,11 +978,7 @@ CORBA_ORB::create_stub_object (const TAO_ObjectKey &key, // @@ Fred, please change this code to use auto_ptr<> and // automatically deallocate the temporary objects. Alternatively // consider about using references ;-) - TAO_MProfile *mp; - ACE_NEW_THROW_EX (mp, - TAO_MProfile (1), - CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_MAYBE)); - ACE_CHECK_RETURN (stub); + TAO_MProfile mp (1); TAO_ORB_Parameters *orb_params = this->orb_core_->orb_params (); @@ -996,7 +992,7 @@ CORBA_ORB::create_stub_object (const TAO_ObjectKey &key, CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_MAYBE)); ACE_CHECK_RETURN (stub); - mp->give_profile (pfile); + mp.give_profile (pfile); ACE_NEW_THROW_EX (stub, TAO_Stub (id, mp, this->orb_core_), @@ -1486,10 +1482,7 @@ CORBA_ORB::iiop_string_to_object (const char *string, // _narrow will be required to make an expensive remote "is_a" call. // Allocate a Multiple Profile with the given no. of profiles. - TAO_MProfile *mp; - ACE_NEW_RETURN (mp, - TAO_MProfile (1), - obj); + TAO_MProfile mp (1); TAO_Profile* pfile; ACE_NEW_RETURN (pfile, @@ -1498,7 +1491,7 @@ CORBA_ORB::iiop_string_to_object (const char *string, ACE_CHECK_RETURN (obj); // pfile refcount == 1 - mp->give_profile (pfile); + mp.give_profile (pfile); // Now make the TAO_Stub ... TAO_Stub *data; @@ -1583,7 +1576,7 @@ CORBA_ORB::iioploc_string_to_object (const char *string, // Now make the TAO_Stub ... TAO_Stub *data; ACE_NEW_RETURN (data, - TAO_Stub ((char *) 0, &mp, this->orb_core_), + TAO_Stub ((char *) 0, mp, this->orb_core_), CORBA::Object::_nil ()); // Create the CORBA level proxy. diff --git a/TAO/tao/Object.cpp b/TAO/tao/Object.cpp index 11e310b36ab..fbb2a5def86 100644 --- a/TAO/tao/Object.cpp +++ b/TAO/tao/Object.cpp @@ -270,10 +270,10 @@ CORBA_Object::_create_request (CORBA::Context_ptr ctx, { TAO_THROW (CORBA::NO_IMPLEMENT ()); } - request = new CORBA::Request (this, - operation, - arg_list, - result, + request = new CORBA::Request (this, + operation, + arg_list, + result, req_flags, TAO_IN_ENV); } @@ -295,10 +295,10 @@ CORBA_Object::_create_request2 (CORBA::Context_ptr ctx, { TAO_THROW (CORBA::NO_IMPLEMENT ()); } - request = new CORBA::Request (this, - operation, - arg_list, - result, + request = new CORBA::Request (this, + operation, + arg_list, + result, req_flags, TAO_IN_ENV); } @@ -308,7 +308,7 @@ CORBA_Object::_request (const CORBA::Char *operation, CORBA::Environment &TAO_IN_ENV) { TAO_IN_ENV.clear (); - return new CORBA::Request (this, + return new CORBA::Request (this, operation, TAO_IN_ENV); } @@ -493,7 +493,7 @@ operator>> (TAO_InputCDR& cdr, CORBA_Object*& x) } // get a profile container to store all profiles in the IOR. - auto_ptr<TAO_MProfile> mp (new TAO_MProfile (profile_count)); + TAO_MProfile mp (profile_count); while (profile_count-- != 0 && cdr.good_bit ()) { @@ -574,7 +574,7 @@ operator>> (TAO_InputCDR& cdr, CORBA_Object*& x) break; case 1: default: - mp->give_profile (pfile); + mp.give_profile (pfile); // all other return values indicate success // we do not decrement reference count on profile since we // are giving it to the MProfile! @@ -584,7 +584,7 @@ operator>> (TAO_InputCDR& cdr, CORBA_Object*& x) } // while loop // make sure we got some profiles! - if (mp->profile_count () == 0) + if (mp.profile_count () == 0) { ACE_DEBUG ((LM_DEBUG, "no IIOP v%d.%d (or earlier) profile in IOR!\n", @@ -597,7 +597,7 @@ operator>> (TAO_InputCDR& cdr, CORBA_Object*& x) // TAO_Stub will make a copy of mp! TAO_Stub *objdata; ACE_NEW_RETURN (objdata, TAO_Stub (type_hint._retn (), - mp.get (), + mp, cdr.orb_core ()), 0); if (objdata == 0) diff --git a/TAO/tao/Pluggable.cpp b/TAO/tao/Pluggable.cpp index 3a1cd46767f..051c17f07f4 100644 --- a/TAO/tao/Pluggable.cpp +++ b/TAO/tao/Pluggable.cpp @@ -6,6 +6,12 @@ #include "tao/Environment.h" #include "tao/GIOP.h" +#if !defined (__ACE_INLINE__) +# include "tao/Pluggable.i" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(tao, Pluggable, "$Id$") + TAO_Connector_Registry::TAO_Connector_Registry (void) : iiop_connector_ (0) { diff --git a/TAO/tao/Pluggable.h b/TAO/tao/Pluggable.h index 52a04090472..8e28e8b56af 100644 --- a/TAO/tao/Pluggable.h +++ b/TAO/tao/Pluggable.h @@ -182,6 +182,9 @@ class TAO_Export TAO_Profile // @@ Fred, please fill in here. // public: + TAO_Profile (void); + // Constructor + virtual CORBA::ULong tag (void) const = 0; // The tag, each concrete class will have a specific tag value. // @@ Fred, any reason this cannot be implemented in the base class? @@ -240,24 +243,11 @@ public: // Obtain the object key, return 0 if the profile cannot be parsed. // The memory is owned by this object (not given to the caller). - virtual void forward_to (TAO_MProfile *mprofiles) = 0; - // object will assume ownership for this object!! - // @@ Fred: this is a bit counterintuitive, the usual rules CORBA - // are: - // 1) Memory passed to an operations is owned by the caller. - // 2) Memory returned from a call is owned by the caller. - // - // C++ is more flexible about this but the common rule is: - // 1) Pointers returned are owned by the callee. - // 2) Pointers passed are owned by the caller. - // - // One good thing about references it that it leaves no ambiguity - // about this. - // The principle of least surprize will recommend that you use - // any of the approaches above, but not the protocol that you propose. + void forward_to (TAO_MProfile *mprofiles); + // Keep a pointer to the forwarded profile - virtual TAO_MProfile *forward_to (void) = 0; - // copy of MProfile, user must delete. + TAO_MProfile* forward_to (void); + // MProfile accessor virtual CORBA::Boolean is_equivalent (TAO_Profile* other_profile, CORBA::Environment &env) = 0; @@ -291,11 +281,14 @@ public: // @@ Fred: reference counting can be implemented in the base class! protected: - virtual TAO_MProfile *forward_to_i (void) = 0; + TAO_MProfile *forward_to_i (void); // this object keeps ownership of this object virtual ~TAO_Profile (void); // If you have a virtual method you need a virtual dtor. + +private: + TAO_MProfile* forward_to_; }; class TAO_Export TAO_Acceptor @@ -446,4 +439,8 @@ private: // equil to the IOP_TYPE and value a pointer to the Connector. }; +#if defined (__ACE_INLINE__) +# include "tao/Pluggable.i" +#endif /* __ACE_INLINE__ */ + #endif /* TAO_PLUGGABLE_H */ diff --git a/TAO/tao/Pluggable.i b/TAO/tao/Pluggable.i new file mode 100644 index 00000000000..4fcf113b6e6 --- /dev/null +++ b/TAO/tao/Pluggable.i @@ -0,0 +1,25 @@ +// $Id$ + +ACE_INLINE +TAO_Profile::TAO_Profile (void) + : forward_to_ (0) +{ +} + +ACE_INLINE void +TAO_Profile::forward_to (TAO_MProfile *mprofiles) +{ + this->forward_to_ = mprofiles; +} + +ACE_INLINE TAO_MProfile * +TAO_Profile::forward_to (void) +{ + return this->forward_to_; +} + +ACE_INLINE TAO_MProfile * +TAO_Profile::forward_to_i (void) +{ + return this->forward_to_; +} diff --git a/TAO/tao/Stub.cpp b/TAO/tao/Stub.cpp index dfc7e67b32c..084243fcc68 100644 --- a/TAO/tao/Stub.cpp +++ b/TAO/tao/Stub.cpp @@ -61,7 +61,7 @@ ACE_TIMEPROBE_EVENT_DESCRIPTIONS (TAO_TAO_Stub_Timeprobe_Description, #endif /* ACE_ENABLE_TIMEPROBES */ TAO_Stub::TAO_Stub (char *repository_id, - TAO_MProfile &profiles, + const TAO_MProfile &profiles, TAO_ORB_Core* orb_core) : type_id (repository_id), base_profiles_ ((CORBA::ULong) 0), @@ -92,86 +92,9 @@ TAO_Stub::TAO_Stub (char *repository_id, this->profile_lock_ptr_ = this->orb_core_->client_factory ()->create_iiop_profile_lock (); - this->set_base_profiles (&profiles); -} - -TAO_Stub::TAO_Stub (char *repository_id, - TAO_MProfile *profiles, - TAO_ORB_Core* orb_core) - : type_id (repository_id), - base_profiles_ ((CORBA::ULong) 0), - forward_profiles_ (0), - profile_in_use_ (0), - profile_lock_ptr_ (0), - profile_success_ (0), - // what about ACE_SYNCH_MUTEX refcount_lock_ - refcount_ (1), - use_locate_request_ (0), - first_locate_request_ (0), - orb_core_ (orb_core) -{ - if (this->orb_core_ == 0) - { - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - "TAO: (%P|%t) TAO_Stub created with default " - "ORB core\n")); - } - this->orb_core_ = TAO_ORB_Core_instance (); - } - - // @@ does this need to be freed? - this->profile_lock_ptr_ = - this->orb_core_->client_factory ()->create_iiop_profile_lock (); - this->set_base_profiles (profiles); } -#if 0 -TAO_Stub::TAO_Stub (char *repository_id, - TAO_Profile *profile) - : type_id (repository_id), - base_profiles_ ((CORBA::ULong) 0), - forward_profiles_ (0), - profile_in_use_ (0), - profile_lock_ptr_ (0), - profile_success_ (0), - // what about ACE_SYNCH_MUTEX refcount_lock_ - refcount_ (1), - use_locate_request_ (0), - first_locate_request_ (0) -{ - // @@ XXX need to verify type and deal with wrong types - - this->profile_lock_ptr_ = - this->orb_core_->client_factory ()->create_iiop_profile_lock (); - - base_profiles_.set (1); - - base_profiles_.give_profile (profile); - - reset_base (); - -} - -TAO_Stub::TAO_Stub (char *repository_id) - : type_id (repository_id), - base_profiles_ ((CORBA::ULong) 0), - forward_profiles_ (0), - profile_in_use_ (0), - profile_lock_ptr_ (0), - profile_success_ (0), - // what about ACE_SYNCH_MUTEX refcount_lock_ - refcount_ (1), - use_locate_request_ (0), - first_locate_request_ (0) -{ - this->profile_lock_ptr_ = - this->orb_core_->client_factory ()->create_iiop_profile_lock (); -} -#endif /* 0 */ - // Quick'n'dirty hash of objref data, for partitioning objrefs into // sets. // @@ -181,7 +104,7 @@ TAO_Stub::TAO_Stub (char *repository_id) // can get different values, depending on the profile_in_use!! CORBA::ULong TAO_Stub::hash (CORBA::ULong max, - CORBA::Environment &env) + CORBA::Environment &env) { // we rely on the profile object to has it's address info if (profile_in_use_) @@ -198,7 +121,7 @@ TAO_Stub::hash (CORBA::ULong max, // @@ Two object references are the same if any two profiles are the same! CORBA::Boolean TAO_Stub::is_equivalent (CORBA::Object_ptr other_obj, - CORBA::Environment &env) + CORBA::Environment &env) { if (CORBA::is_nil (other_obj) == 1) return 0; @@ -914,7 +837,7 @@ TAO_Stub::set_policy_overrides ( TAO_Stub* stub; ACE_NEW_RETURN (stub, TAO_Stub (CORBA::string_dup (this->type_id.in ()), - this->get_profiles (), + this->base_profiles_, this->orb_core_), 0); stub->policies_ = policy_manager.release (); @@ -942,6 +865,33 @@ TAO_Stub::validate_connection ( return 0; } +void +TAO_Stub::add_forward_profiles (const TAO_MProfile &mprofiles) +{ + // we assume that the profile_in_use_ is being + // forwarded! Grab the lock so things don't change. + ACE_MT (ACE_GUARD (ACE_Lock, + guard, + *this->profile_lock_ptr_)); + + TAO_MProfile *now_pfiles = this->forward_profiles_; + if (now_pfiles == 0) + now_pfiles = &this->base_profiles_; + + ACE_NEW (this->forward_profiles_, + TAO_MProfile (mprofiles)); + + // forwarded profile points to the new IOR (profiles) + this->profile_in_use_->forward_to (this->forward_profiles_); + + // new profile list points back to the list which was forwarded. + this->forward_profiles_->forward_from (now_pfiles); + + // make sure we start at the beginning of mprofiles + this->forward_profiles_->rewind (); +} + + #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class auto_ptr<TAO_Policy_Manager_Impl>; diff --git a/TAO/tao/Stub.h b/TAO/tao/Stub.h index 15685eb7c38..d1509c76a92 100644 --- a/TAO/tao/Stub.h +++ b/TAO/tao/Stub.h @@ -43,6 +43,10 @@ class TAO_Policy_Manager_Impl; enum TAO_Param_Type { + // @@ Is there any use for this enum? I would assume that the + // similar ones on corbfwd.h are enough! + // @@ Jeff: can you check into that? + // = TITLE // TAO_Param_Type // =DESCRIPTION @@ -305,13 +309,7 @@ public: // Our Constructors ... TAO_Stub (char *repository_id, - TAO_MProfile *profiles, - TAO_ORB_Core *orb_core); - // Construct from a repository ID and a pointer to list of - // profiles. Assumes ownership of the profiles. - - TAO_Stub (char *repository_id, - TAO_MProfile &profiles, + const TAO_MProfile &profiles, TAO_ORB_Core *orb_core); // Construct from a repository ID and a list of profiles. @@ -368,11 +366,11 @@ public: // returns TRUE if a connection was successful with at least // one profile. - TAO_Profile *set_base_profiles (TAO_MProfile *mprofiles); + TAO_Profile *set_base_profiles (const TAO_MProfile& mprofiles); // Initialize the base_profiles_ and set profile_in_use_ to // reference the first profile. - void add_forward_profiles (TAO_MProfile *mprofiles); + void add_forward_profiles (const TAO_MProfile &mprofiles); // THREAD SAFE. // set the forward_profiles. This object will assume ownership of // this TAO_MProfile object!! @@ -432,10 +430,6 @@ private: // NON-THREAD-SAFE. utility method for next_profile. private: - // @@ For now, we keep track of transport specific profiles here, - // but in the next iteration this will go away ... only transport - // neutral info is kept here => TAO_Stub should also go away! - // fredk TAO_MProfile base_profiles_; // ordered list of profiles for this object. TAO_MProfile *forward_profiles_; diff --git a/TAO/tao/Stub.i b/TAO/tao/Stub.i index fff7c3cc209..242203aaba2 100644 --- a/TAO/tao/Stub.i +++ b/TAO/tao/Stub.i @@ -72,10 +72,8 @@ ACE_INLINE void TAO_Stub::reset_forward (void) { - while (forward_profiles_) + while (this->forward_profiles_ != 0) forward_back_one (); - - forward_profiles_ = 0; } ACE_INLINE @@ -145,7 +143,7 @@ ACE_INLINE TAO_MProfile * TAO_Stub::get_profiles (void) { - return new TAO_MProfile (&base_profiles_); + return new TAO_MProfile (base_profiles_); } ACE_INLINE @@ -154,7 +152,8 @@ TAO_Stub::next_forward_profile (void) { TAO_Profile *pfile_next = 0; - while (forward_profiles_ && (pfile_next = forward_profiles_->get_next ()) == 0) + while (this->forward_profiles_ + && (pfile_next = forward_profiles_->get_next ()) == 0) // that was the last profile. Now we clean up our forward profiles. // since we own the forward MProfiles, we must delete them when done. forward_back_one (); @@ -220,7 +219,7 @@ TAO_Stub::valid_profile (void) ACE_INLINE TAO_Profile * -TAO_Stub::set_base_profiles (TAO_MProfile *mprofiles) +TAO_Stub::set_base_profiles (const TAO_MProfile &mprofiles) { ACE_MT (ACE_GUARD_RETURN (ACE_Lock, guard, @@ -236,31 +235,6 @@ TAO_Stub::set_base_profiles (TAO_MProfile *mprofiles) } ACE_INLINE -void -TAO_Stub::add_forward_profiles (TAO_MProfile *mprofiles) -{ - // we assume that the profile_in_use_ is being - // forwarded! Grab the lock so things don't change. - ACE_MT (ACE_GUARD (ACE_Lock, - guard, - *this->profile_lock_ptr_)); - - // forwarded profile points to the new IOR (profiles) - profile_in_use_->forward_to (mprofiles); - - TAO_MProfile *now_pfiles = forward_profiles_ ? forward_profiles_ : &base_profiles_; - - // new profile list points back to the list which was forwarded. - mprofiles->forward_from (now_pfiles); - - forward_profiles_ = mprofiles; - - // make sure we start at the beginning of mprofiles - forward_profiles_->rewind (); - -} - -ACE_INLINE CORBA::Boolean TAO_Stub::next_profile_retry (void) { diff --git a/TAO/tao/UIOP_Profile.cpp b/TAO/tao/UIOP_Profile.cpp index 99807b48ef0..5b4cca477a6 100644 --- a/TAO/tao/UIOP_Profile.cpp +++ b/TAO/tao/UIOP_Profile.cpp @@ -31,8 +31,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const ACE_UNIX_Addr& addr, object_addr_ (addr), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { this->set (addr); int l = ACE_OS::strlen (object_key); @@ -54,8 +53,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const ACE_UNIX_Addr& addr, object_addr_ (addr), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { this->set (addr); this->create_body (); @@ -72,8 +70,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const ACE_UNIX_Addr& addr, object_addr_ (addr), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { this->set (addr); int l = ACE_OS::strlen (object_key); @@ -96,8 +93,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const ACE_UNIX_Addr& addr, object_addr_ (addr), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { this->set (addr); this->create_body (); @@ -113,8 +109,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const char* rendezvous_point, object_addr_ (rendezvous_point), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { if (rendezvous_point) @@ -138,8 +133,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const char* rendezvous_point, object_addr_ (addr), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { if (rendezvous_point) @@ -163,8 +157,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const char* rendezvous_point, object_addr_ (rendezvous_point), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { ACE_UNUSED_ARG (version); @@ -184,8 +177,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const TAO_UIOP_Profile *pfile) object_addr_(pfile->object_addr_), hint_(0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { ACE_NEW (this->rendezvous_point_, @@ -204,8 +196,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const TAO_UIOP_Profile &pfile) object_addr_(pfile.object_addr_), hint_(0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { ACE_NEW (this->rendezvous_point_, @@ -224,8 +215,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const TAO_IOP_Version &version) object_addr_ (), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { } @@ -239,8 +229,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const char *string, object_addr_ (), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { parse_string (string, env); } @@ -254,8 +243,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (void) object_addr_ (), hint_ (0), // what about refcount_lock_ (), - refcount_ (1), - forward_to_ (0) + refcount_ (1) { } @@ -295,12 +283,6 @@ TAO_UIOP_Profile::~TAO_UIOP_Profile (void) delete [] this->rendezvous_point_; this->rendezvous_point_ = 0; - - if (forward_to_) - { - delete forward_to_; - } - } // return codes: @@ -620,30 +602,6 @@ TAO_UIOP_Profile::_decr_refcnt (void) return 0; } - -void -TAO_UIOP_Profile::forward_to (TAO_MProfile *mprofiles) -{ - // we assume ownership of the profile list!! - if (forward_to_) - delete this->forward_to_; - - ACE_NEW (this->forward_to_, - TAO_MProfile (mprofiles)); - -} - -TAO_MProfile * -TAO_UIOP_Profile::forward_to (void) -{ - TAO_MProfile *temp; - - ACE_NEW_RETURN (temp, - TAO_MProfile (this->forward_to_), - 0); - return temp; -} - CORBA::String TAO_UIOP_Profile::to_string (CORBA::Environment &env) { diff --git a/TAO/tao/UIOP_Profile.h b/TAO/tao/UIOP_Profile.h index 0c6c5c9125c..d9d4f75f577 100644 --- a/TAO/tao/UIOP_Profile.h +++ b/TAO/tao/UIOP_Profile.h @@ -137,12 +137,6 @@ public: TAO_ObjectKey *_key (CORBA::Environment &env); // Return a pointer to the Object Key. - virtual void forward_to (TAO_MProfile *mprofiles); - // Client object will assume ownership for this object!! - - virtual TAO_MProfile *forward_to (void); - // copy of MProfile, user must delete. - CORBA::Boolean is_equivalent (TAO_Profile *other_profile, CORBA::Environment &env); // Return true if this profile is equivalent to other_profile. Two @@ -198,11 +192,6 @@ private: int set (const ACE_UNIX_Addr &addr); // helper method to set the UNIX_Addr. - virtual TAO_MProfile *forward_to_i (void); - // reference to the TAO_MProfile which the current profile was - // forwarded to. This object keeps ownership. Note that this - // method is NOT thread-safe, so it must be called with locks held. - void create_body (void); // Does the work for <add_profile>. diff --git a/TAO/tao/UIOP_Profile.i b/TAO/tao/UIOP_Profile.i index 9e309c9e193..d4b9dc66157 100644 --- a/TAO/tao/UIOP_Profile.i +++ b/TAO/tao/UIOP_Profile.i @@ -72,11 +72,4 @@ TAO_UIOP_Profile::_nil (void) return (TAO_UIOP_Profile *) 0; } -ACE_INLINE TAO_MProfile * -TAO_UIOP_Profile::forward_to_i (void) -{ - return this->forward_to_; -} - - #endif /* !defined ACE_LACKS_UNIX_DOMAIN_SOCKETS */ |