From df9d520cf4f1f97b7ae6592a3693e724fce96f12 Mon Sep 17 00:00:00 2001 From: fredk Date: Fri, 21 May 1999 21:29:47 +0000 Subject: *** empty log message *** --- TAO/tao/Acceptor_Registry.cpp | 35 +++++++++++++++++++++++++++++++++++ TAO/tao/IIOP_Acceptor.cpp | 35 +++++++++++++++++++++++++++++++---- TAO/tao/IIOP_Acceptor.h | 8 ++++++-- TAO/tao/MProfile.h | 12 +++++++++++- TAO/tao/MProfile.i | 36 ++++++++++++++++++++++++++++++++++++ TAO/tao/ORB.cpp | 13 ++----------- TAO/tao/Pluggable.h | 16 +++++++--------- TAO/tao/UIOP_Acceptor.cpp | 26 +++++++++++++++++++++++++- TAO/tao/UIOP_Acceptor.h | 7 ++++--- 9 files changed, 157 insertions(+), 31 deletions(-) diff --git a/TAO/tao/Acceptor_Registry.cpp b/TAO/tao/Acceptor_Registry.cpp index 7f2f1d0a741..d9a2eb33dc4 100644 --- a/TAO/tao/Acceptor_Registry.cpp +++ b/TAO/tao/Acceptor_Registry.cpp @@ -20,6 +20,41 @@ TAO_Acceptor_Registry::~TAO_Acceptor_Registry (void) { } +size_t +TAO_Acceptor_Registry::endpoint_count (void) +{ + int count; + TAO_AcceptorSetItor end = + this->acceptors_.end (); + TAO_AcceptorSetItor acceptor = + this->acceptors_.begin (); + + for (; acceptor != end; acceptor++) + { + count += (*acceptor)->endpoint_count (); + } + + return count; +} + +TAO_Mprofile * +TAO_Acceptor_Registry::make_mprofile (const TAO_ObjectKey &object_key, + TAO_MProfile *&mprofile) +{ + TAO_AcceptorSetItor end = + this->acceptors_.end (); + TAO_AcceptorSetItor acceptor = + this->acceptors_.begin (); + + for (; acceptor != end; acceptor++) + { + if ((*acceptor)->create_mprofile (object_key, mprofile) == -1) + return -1; + } + + return 0; +} + TAO_Acceptor * TAO_Acceptor_Registry::get_acceptor (CORBA::ULong tag) { diff --git a/TAO/tao/IIOP_Acceptor.cpp b/TAO/tao/IIOP_Acceptor.cpp index 605a3989355..3d6736f0907 100644 --- a/TAO/tao/IIOP_Acceptor.cpp +++ b/TAO/tao/IIOP_Acceptor.cpp @@ -30,21 +30,38 @@ TAO_IIOP_Acceptor::TAO_IIOP_Acceptor (void) // And isn't this the right place to setup the tagged components of // a v1.[12] profile? -// @@ Fred&Ossama: We need to check this interface: a single +/s/ @@ Fred&Ossama: We need to check this interface: a single // TAO_Acceptor may be bound to multiple addresses (think of a // multihomed machine with an acceptor listening on the wildcard // address), hence the "Right Thing" seems to be that we pass an // MProfile that is filled up by the TAO_Acceptor class. -TAO_Profile * -TAO_IIOP_Acceptor::create_profile (TAO_ObjectKey &object_key) +int +TAO_IIOP_Acceptor::create_mprofile (const TAO_ObjectKey &object_key, + TAO_MProfile *&mprofile) { ACE_INET_Addr new_address; if (base_acceptor_.acceptor ().get_local_addr (new_address) == -1) return 0; - return new TAO_IIOP_Profile (new_address, object_key); + // we only make one + int count = mprofile->profile_count (); + if ((mprofile->size () - count) < 1) + { + if (mprofile->grow (count + 1) == -1) + return -1; + } + + TAO_IIOP_Profile pfile; + ACE_NEW_RETURN (pfile + TAO_IIOP_Profile (new_address, object_key), + -1); + + if (mprofile->give_profile (pfile) == -1) + return -1; + + return 0; } int @@ -89,3 +106,13 @@ TAO_IIOP_Acceptor::open (TAO_ORB_Core *orb_core, return 0; // Success } + + +CORBA::ULong +TAO_IIOP_Profile::endpoint_count (void) +{ + // @@ for now just assume one! + // we should take a look at the local address, if it is zero then + // get the list of available IP interfaces and return this number. + return 1; +} diff --git a/TAO/tao/IIOP_Acceptor.h b/TAO/tao/IIOP_Acceptor.h index d386fae50ed..8ab67f60a41 100644 --- a/TAO/tao/IIOP_Acceptor.h +++ b/TAO/tao/IIOP_Acceptor.h @@ -52,8 +52,9 @@ public: int open (TAO_ORB_Core *orb_core, ACE_CString &address); // initialize acceptor for this address. - TAO_Profile *create_profile (TAO_ObjectKey& object_key); - // create profile object for this Acceptor using the SAP + int create_mprofile (const TAO_ObjectKey &object_key, + TAO_MProfile *&mprofile); + // create profile objects for this Acceptor using the SAP // (service access point, Host and Port) and object_key. // = See TAO_Acceptor @@ -62,6 +63,9 @@ public: ACE_Event_Handler *acceptor (void); // Return the underlying acceptor object, ACE_Acceptor + CORBA::ULong endpoint_count (void); + // return the number of profiles this will generate + private: TAO_IIOP_BASE_ACCEPTOR base_acceptor_; // the concrete acceptor, as a pointer to it's base class. diff --git a/TAO/tao/MProfile.h b/TAO/tao/MProfile.h index d5b3ff57494..13de8fa3330 100644 --- a/TAO/tao/MProfile.h +++ b/TAO/tao/MProfile.h @@ -63,11 +63,17 @@ public: int set (CORBA::ULong sz); // Inits MProfile to hold sz TAO_Profiles. + // NOT THREAD SAFE 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!! + // NOT THREAD SAFE + + int grow (CORBA::ULong sz); + // increate the number of profiles this object can hold. + // NOT THREAD SAFE TAO_Profile_ptr get_cnext (void); // Treat as a circular list. @@ -94,7 +100,11 @@ public: // Returns the index for the current profile. CORBA::ULong profile_count (void) const; - // Returns the number of profiles stored in the list (last_). + // Returns the number of profiles stored in the list (last_+1). + + CORBA::ULong size (void) const; + // return the maximum number of profiles that can be stored in this + // container, (size_+1) const TAO_Profile* get_profile (CORBA::ULong index) const; // Return the profile at position . diff --git a/TAO/tao/MProfile.i b/TAO/tao/MProfile.i index a4291144f82..f7da6dfa941 100644 --- a/TAO/tao/MProfile.i +++ b/TAO/tao/MProfile.i @@ -163,6 +163,12 @@ TAO_MProfile::profile_count (void) const return this->last_; } +ACE_INLINE CORBA::ULong +TAO_MProfile::size (void) const; +{ + return this->size_; +} + ACE_INLINE const TAO_Profile* TAO_MProfile::get_profile (CORBA::ULong index) const { @@ -176,3 +182,33 @@ TAO_MProfile::pfiles (void) const { return this->pfiles_; } + + +// Not thread safe! +ACE_INLINE int +TAO_MProfile::grow (CORBA::ULong sz) +{ + if (sz <= this->size_) + return 0; + + // get the additional space + TAO_Profile_ptr *new_pfiles, *old_pfiles; + ACE_NEW_RETURN (pfiles, + TAO_Profile_ptr[sz], + -1); + + old_pfiles = this->pfiles_; + + // got it, now copy profiles + for (TAO_PHandle h = 0; h < this->size_; h++) + { + new_pfiles[h] = old_pfiles[h]; + old_pfiles[h] = 0; + } + + this->pfiles_ = new_pfiles; + this->size_ = sz; + delete [] old_pfiles; + + return 0; +} diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp index c222216d6b0..e94b243bd47 100644 --- a/TAO/tao/ORB.cpp +++ b/TAO/tao/ORB.cpp @@ -940,19 +940,12 @@ CORBA_ORB::create_stub_object (const TAO_ObjectKey &key, TAO_Stub *stub = 0; - // First we create a profile list, well actually a list of one! - // @@ should go to the acceptor for this, the orb delegates to the acceptor - // to create Profiles! - TAO_MProfile mp (1); + // First we create a profile list, well actually the empty container + TAO_MProfile mp (0); TAO_ORB_Parameters *orb_params = this->orb_core_->orb_params (); - // @@ Ug, broken. Again, we need to go to the acceptor registry - // (when we got one) for this!!! [fredk] - // @@ Fred&Ossama: You guys have one now ;-) I still believe that - // the right way to do this is something along these lines: - // // size_t pfile_count = // this->orb_core_->acceptor_registry ()->count_profiles (); // { @@ -969,8 +962,6 @@ CORBA_ORB::create_stub_object (const TAO_ObjectKey &key, // mp.give_profile (new Right_Endpoint (e, key)); // } // } - // - // What do you think? TAO_IIOP_Profile *pfile; ACE_NEW_THROW_EX (pfile, diff --git a/TAO/tao/Pluggable.h b/TAO/tao/Pluggable.h index ab943ecf548..89eaa4ab789 100644 --- a/TAO/tao/Pluggable.h +++ b/TAO/tao/Pluggable.h @@ -286,16 +286,9 @@ public: TAO_Acceptor (CORBA::ULong tag); - virtual TAO_Profile *create_profile (TAO_ObjectKey &object_key) = 0; + virtual int create_mprofile (const TAO_ObjectKey &object_key, + TAO_MProfile *&mprofile) = 0; // Create the corresponding profile for this endpoint. - // @@ Fred: that should be const. - // @@ Fred: we haven't thought about acceptors that service more - // than one endpoint (for example: listening on sap_any). Maybe a - // better interface is: - // virtual int add_profiles (const TAO_ObjectKey& key, - // TAO_MProfile& mprofile) const = 0; - // // Add the profiles serviced by this acceptor to the - // // list. Use to fill in the profiles. virtual int open (TAO_ORB_Core *orb_core, ACE_CString &address) = 0; // method to initialize acceptor for address. @@ -309,6 +302,11 @@ public: CORBA::ULong tag (void) const; // The tag, each concrete class will have a specific tag value. + CORBA::ULong endpoint_count (void); + // returns the number of endpoints this acceptor is listening on. This + // is used for determining how many profiles will be generated + // for this acceptor. + virtual ~TAO_Acceptor (void); // Destructor diff --git a/TAO/tao/UIOP_Acceptor.cpp b/TAO/tao/UIOP_Acceptor.cpp index e19d3cf51e4..2a8416a9c37 100644 --- a/TAO/tao/UIOP_Acceptor.cpp +++ b/TAO/tao/UIOP_Acceptor.cpp @@ -39,11 +39,35 @@ TAO_UIOP_Acceptor::TAO_UIOP_Acceptor (void) } TAO_Profile * -TAO_UIOP_Acceptor::create_profile (TAO_ObjectKey &) +TAO_UIOP_Acceptor::create_mprofile (const TAO_ObjectKey &object_key, + TAO_MProfile *&mprofile) { + ACE_UNIX_Addr new_address; + + if (base_acceptor_.acceptor ().get_local_addr (new_address) == -1) + return 0; + + // we only make one + int count = mprofile->profile_count (); + if ((mprofile->size () - count) < 1) + { + if (mprofile->grow (count + 1) == -1) + return -1; + } + + TAO_UIOP_Profile pfile; + ACE_NEW_RETURN (pfile + TAO_UIOP_Profile (new_address, object_key), + -1); + + if (mprofile->give_profile (pfile) == -1) + return -1; + return 0; } +} + int TAO_UIOP_Acceptor::is_collocated (const TAO_Profile* pfile) { diff --git a/TAO/tao/UIOP_Acceptor.h b/TAO/tao/UIOP_Acceptor.h index 69836ca30ba..b40d76c6da7 100644 --- a/TAO/tao/UIOP_Acceptor.h +++ b/TAO/tao/UIOP_Acceptor.h @@ -63,9 +63,10 @@ public: int open (TAO_ORB_Core *orb_core, ACE_CString &address); // initialize acceptor for this address. - virtual TAO_Profile *create_profile (TAO_ObjectKey& object_key); - // create profile object for this Acceptor using the SAP - // (service access point, Host and Port) and object_key. + int create_mprofile (const TAO_ObjectKey &object_key, + TAO_MProfile *&mprofile); + // create profile objects for this Acceptor using the SAP + // (service access point) and object_key. // = See TAO_Acceptor virtual int is_collocated (const TAO_Profile*); -- cgit v1.2.1