diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-11-12 06:36:01 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-11-12 06:36:01 +0000 |
commit | c0cd92a45716c2216f1935aae36c5be883798831 (patch) | |
tree | 2db3f2a3b9ef34785e4109c4ab24472153d4392f /ace | |
parent | fa781759f6acbe34289f859bab16b5f274afc974 (diff) | |
download | ATCD-c0cd92a45716c2216f1935aae36c5be883798831.tar.gz |
ChangeLogTag: Fri Nov 12 00:30:41 1999 Irfan Pyarali <irfan@cs.wustl.edu>
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Cached_Connect_Strategy_T.cpp | 22 | ||||
-rw-r--r-- | ace/Cached_Connect_Strategy_T.h | 5 | ||||
-rw-r--r-- | ace/Connector.cpp | 13 | ||||
-rw-r--r-- | ace/Strategies.h | 7 | ||||
-rw-r--r-- | ace/Strategies_T.cpp | 29 | ||||
-rw-r--r-- | ace/Strategies_T.h | 12 | ||||
-rw-r--r-- | ace/Svc_Handler.cpp | 7 | ||||
-rw-r--r-- | ace/Svc_Handler.h | 5 |
8 files changed, 69 insertions, 31 deletions
diff --git a/ace/Cached_Connect_Strategy_T.cpp b/ace/Cached_Connect_Strategy_T.cpp index c20a4b3a80e..8e0bb7ada5c 100644 --- a/ace/Cached_Connect_Strategy_T.cpp +++ b/ace/Cached_Connect_Strategy_T.cpp @@ -50,7 +50,7 @@ ACE_Cached_Connect_Strategy_Ex<ACE_T2>::~ACE_Cached_Connect_Strategy_Ex (void) { #if defined (ACE_HAS_BROKEN_EXTENDED_TEMPLATES) cleanup (); -#else +#else // Close down all cached service handlers. for (ACE_TYPENAME CONNECTION_CACHE::ITERATOR iter = this->connection_cache_.begin (); iter != this->connection_cache_.end (); @@ -188,6 +188,10 @@ ACE_Cached_Connect_Strategy_Ex<ACE_T2>::find_or_create_svc_handler_i flags, perms) == -1) { + // Close the svc handler and reset <sh>. + sh->close (0); + sh = 0; + return -1; } else @@ -196,7 +200,13 @@ ACE_Cached_Connect_Strategy_Ex<ACE_T2>::find_or_create_svc_handler_i if (this->connection_cache_.bind (search_addr, sh, entry) == -1) - return -1; + { + // Close the svc handler and reset <sh>. + sh->close (0); + sh = 0; + + return -1; + } // Set the recycler and the recycling act this->assign_recycler (sh, this, entry); @@ -401,8 +411,14 @@ ACE_Cached_Connect_Strategy_Ex<ACE_T2>::mark_as_closed_i (const void *recycling_ } template <ACE_T1> int -ACE_Cached_Connect_Strategy_Ex<ACE_T2>::cleanup_hint_i (const void *recycling_act) +ACE_Cached_Connect_Strategy_Ex<ACE_T2>::cleanup_hint_i (const void *recycling_act, + void **act_holder) { + // Reset the <*act_holder> in the confines and protection of the + // lock. + if (act_holder) + *act_holder = 0; + // The wonders and perils of ACT CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; diff --git a/ace/Cached_Connect_Strategy_T.h b/ace/Cached_Connect_Strategy_T.h index a178132a1a7..dec8a016d61 100644 --- a/ace/Cached_Connect_Strategy_T.h +++ b/ace/Cached_Connect_Strategy_T.h @@ -117,8 +117,9 @@ protected: virtual ACE_Recyclable_State recycle_state_i (const void *recycling_act) const; // Get/Set <recycle_state> (non-locking version). - virtual int cleanup_hint_i (const void *recycling_act); - // Cleanup hint. + virtual int cleanup_hint_i (const void *recycling_act, + void **act_holder); + // Cleanup hint and reset <*act_holder> to zero if <act_holder != 0>. // = Helpers int check_hint_i (SVC_HANDLER *&sh, diff --git a/ace/Connector.cpp b/ace/Connector.cpp index 6e950be636c..b3493bc7192 100644 --- a/ace/Connector.cpp +++ b/ace/Connector.cpp @@ -412,11 +412,10 @@ ACE_Connector<SH, PR_CO_2>::connect_i (SH *&sh, { ACE_TRACE ("ACE_Connector<SH, PR_CO_2>::connect"); - SH* new_sh = sh; // If the user hasn't supplied us with a <SVC_HANDLER> we'll use the // factory method to create one. Otherwise, things will remain as // they are... - if (this->make_svc_handler (new_sh) == -1) + if (this->make_svc_handler (sh) == -1) return -1; ACE_Time_Value *timeout; @@ -429,7 +428,7 @@ ACE_Connector<SH, PR_CO_2>::connect_i (SH *&sh, int result; if (sh_copy == 0) - result = this->connect_svc_handler (new_sh, + result = this->connect_svc_handler (sh, remote_addr, timeout, local_addr, @@ -437,7 +436,7 @@ ACE_Connector<SH, PR_CO_2>::connect_i (SH *&sh, flags, perms); else - result = this->connect_svc_handler (new_sh, + result = this->connect_svc_handler (sh, *sh_copy, remote_addr, timeout, @@ -459,7 +458,6 @@ ACE_Connector<SH, PR_CO_2>::connect_i (SH *&sh, // here because if something goes wrong that will reset // errno this will be detected by the caller (since -1 is // being returned...). - sh = new_sh; this->create_AST (sh, synch_options); } else @@ -468,15 +466,14 @@ ACE_Connector<SH, PR_CO_2>::connect_i (SH *&sh, ACE_Errno_Guard error (errno); // Make sure to close down the Channel to avoid descriptor // leaks. - if (new_sh) - new_sh->close (0); + if (sh) + sh->close (0); } return -1; } else { // Activate immediately if we are connected. - sh = new_sh; return this->activate_svc_handler (sh); } } diff --git a/ace/Strategies.h b/ace/Strategies.h index 90d62d894f4..91ff0e9a5b8 100644 --- a/ace/Strategies.h +++ b/ace/Strategies.h @@ -111,9 +111,10 @@ public: virtual int mark_as_closed_i (const void *recycling_act) = 0; // Mark as closed.(non-locking version) - - virtual int cleanup_hint (const void *recycling_act) = 0; - // Cleanup as hint. + + virtual int cleanup_hint (const void *recycling_act, + void **act_holder = 0) = 0; + // Cleanup hint and reset <*act_holder> to zero if <act_holder != 0>. protected: ACE_Connection_Recycling_Strategy (void); diff --git a/ace/Strategies_T.cpp b/ace/Strategies_T.cpp index 6c446c2c7db..d60ee48a2de 100644 --- a/ace/Strategies_T.cpp +++ b/ace/Strategies_T.cpp @@ -28,7 +28,7 @@ ACE_Singleton_Strategy<SVC_HANDLER>::open (SVC_HANDLER *sh, { ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::open"); - if (this->delete_svc_handler_ + if (this->delete_svc_handler_ && this->svc_handler_ != 0) delete this->svc_handler_; @@ -641,6 +641,11 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::find_or_c // of the completion of connect(). if (errno == EWOULDBLOCK) errno = ENOTSUP; + + // Close the svc handler and reset <sh>. + sh->close (0); + sh = 0; + return -1; } else @@ -649,7 +654,13 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::find_or_c if (this->connection_map_.bind (search_addr, sh, entry) == -1) - return -1; + { + // Close the svc handler and reset <sh>. + sh->close (0); + sh = 0; + + return -1; + } // Set the recycler and the recycling act this->assign_recycler (sh, this, entry); @@ -970,18 +981,26 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::mark_as_c } template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int -ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cleanup_hint (const void *recycling_act) +ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cleanup_hint (const void *recycling_act, + void **act_holder) { // Excluded other threads from changing cache while we take this // entry out. ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1); - return this->cleanup_hint_i (recycling_act); + return this->cleanup_hint_i (recycling_act, + act_holder); } template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int -ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cleanup_hint_i (const void *recycling_act) +ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cleanup_hint_i (const void *recycling_act, + void **act_holder) { + // Reset the <*act_holder> in the confines and protection of the + // lock. + if (act_holder) + *act_holder = 0; + // The wonders and perils of ACT CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act; diff --git a/ace/Strategies_T.h b/ace/Strategies_T.h index f1587419ea2..dfa9cd95391 100644 --- a/ace/Strategies_T.h +++ b/ace/Strategies_T.h @@ -765,11 +765,12 @@ public: virtual int mark_as_closed_i (const void *recycling_act); // Mark as closed (non-locking version). This method needs to be public - // as it is used in the cleanup of handlers where teh locked version causes + // as it is used in the cleanup of handlers where teh locked version causes // a deadlock. - virtual int cleanup_hint (const void *recycling_act); - // Cleanup hint. + virtual int cleanup_hint (const void *recycling_act, + void **act_holder = 0); + // Cleanup hint and reset <*act_holder> to zero if <act_holder != 0>. // = Define some useful typedefs. typedef ACE_Creation_Strategy<SVC_HANDLER> @@ -826,8 +827,9 @@ protected: virtual ACE_Recyclable_State recycle_state_i (const void *recycling_act) const; // Get/Set <recycle_state> (non-locking version). - virtual int cleanup_hint_i (const void *recycling_act); - // Cleanup hint. + virtual int cleanup_hint_i (const void *recycling_act, + void **act_holder); + // Cleanup hint and reset <*act_holder> to zero if <act_holder != 0>. // = Helpers int check_hint_i (SVC_HANDLER *&sh, diff --git a/ace/Svc_Handler.cpp b/ace/Svc_Handler.cpp index cf3a70748c6..fae1b9799f4 100644 --- a/ace/Svc_Handler.cpp +++ b/ace/Svc_Handler.cpp @@ -189,13 +189,14 @@ ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::shutdown (void) } template <PR_ST_1, ACE_SYNCH_DECL> void -ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::cleanup_hint (void) +ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::cleanup_hint (void **act_holder) { ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::cleanup_hint"); + // Remove as hint. if (this->recycler ()) - this->recycler ()->cleanup_hint (this->recycling_act_); - + this->recycler ()->cleanup_hint (this->recycling_act_, + act_holder); } template <PR_ST_1, ACE_SYNCH_DECL> void diff --git a/ace/Svc_Handler.h b/ace/Svc_Handler.h index 0f66a6fb1c0..bf843a45e2f 100644 --- a/ace/Svc_Handler.h +++ b/ace/Svc_Handler.h @@ -78,9 +78,10 @@ public: // will have no effect (and the accessor will return // ACE_RECYCLABLE_UNKNOWN). - virtual void cleanup_hint (void); + virtual void cleanup_hint (void **act_holder = 0); // When the svc_handle is no longer needed around as a hint, call - // this method. + // this method. In addition, reset <*act_holder> to zero if + // <act_holder != 0>. // = Dynamic linking hooks. virtual int init (int argc, ASYS_TCHAR *argv[]); |