summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-16 01:43:11 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-16 01:43:11 +0000
commit8985600421601bd4409c254e43d138e7eeace12e (patch)
tree4dcfe5dd5063558a1720b62ce91092095ffd8f9e
parent214f9612d1e0cf52b2f0c0100982902d0d28236a (diff)
downloadATCD-8985600421601bd4409c254e43d138e7eeace12e.tar.gz
ChangeLogTag:Thu Jul 15 20:23:39 1999 Irfan Pyarali <irfan@cs.wustl.edu>
-rw-r--r--ChangeLog-99b45
-rw-r--r--ace/Cached_Connect_Strategy_T.cpp122
-rw-r--r--ace/Cached_Connect_Strategy_T.h95
-rw-r--r--ace/Caching_Utility_T.cpp14
-rw-r--r--ace/Cleanup_Strategies_T.cpp14
-rw-r--r--ace/Strategies.h30
-rw-r--r--ace/Strategies.i21
-rw-r--r--ace/Strategies_T.cpp81
-rw-r--r--ace/Strategies_T.h18
-rw-r--r--ace/Strategies_T.i25
-rw-r--r--ace/Svc_Handler.cpp10
-rw-r--r--ace/Svc_Handler.h9
-rw-r--r--tests/Cached_Accept_Conn_Test.cpp2
-rw-r--r--tests/Cached_Conn_Test.cpp82
14 files changed, 394 insertions, 174 deletions
diff --git a/ChangeLog-99b b/ChangeLog-99b
index 44fe9433759..7fdb23e6a1c 100644
--- a/ChangeLog-99b
+++ b/ChangeLog-99b
@@ -1,3 +1,48 @@
+Thu Jul 15 20:23:39 1999 Irfan Pyarali <irfan@cs.wustl.edu>
+
+ * tests/Cached_Conn_Test.cpp (test_connection_management): Changed
+ the test to allow for both one listen endpoint or multiple
+ listen endpoints.
+
+ * ace/Cached_Connect_Strategy_T.cpp:
+ * ace/Strategies_T.cpp
+
+ - find: Since the comparison of
+ REFCOUNTED_HASH_RECYCLABLE_ADDRESS doesn't work very well when
+ trying to find an idle connection (because there are many idle
+ states), we now use the new backet iterator to find a idle
+ connection.
+
+ - check_hint_i: Explicitly checks for idleness; previously it
+ was simple checking !closed.
+
+ * ace/Strategies.h (ACE_Recyclable): Changed ACE_Recyclable::State
+ to ACE_Recyclable_State.
+
+ * ace/Strategies_T.h (ACE_Refcounted_Hash_Recyclable):
+
+ - Added operator!=(ACE_Refcounted_Hash_Recyclable<T>)
+ - Removed operator==(T)
+ - Added T &subject()
+ - Change operator==(ACE_Refcounted_Hash_Recyclable<T>) to check
+ for equality in state and subject.
+
+ * ace/Caching_Utility_T.cpp (minimum): Entries marked
+ ACE_RECYCLABLE_PURGABLE_BUT_NOT_IDLE should also be considered
+ for purging.
+
+ * ace/Cleanup_Strategies_T.cpp (cleanup): The hash map of the
+ connection cache may contain duplicates. Therefore, we are not
+ exactly sure which map entry will be removed when calling
+ unbind(). Therefore, we use the other unbind() which gives us
+ back the value of the entry that was removed. This way will
+ close the correct handler.
+
+ * ace/Svc_Handler.cpp (state): Added a new method that allows the
+ user to explcitly set the state of the Svc_Handler. If the
+ Svc_Handler does not have a recycler, this method will have no
+ effect.
+
Thu Jul 15 16:39:06 1999 Ossama Othman <othman@cs.wustl.edu>
* Makefile:
diff --git a/ace/Cached_Connect_Strategy_T.cpp b/ace/Cached_Connect_Strategy_T.cpp
index 71166894d11..d3bce766985 100644
--- a/ace/Cached_Connect_Strategy_T.cpp
+++ b/ace/Cached_Connect_Strategy_T.cpp
@@ -25,8 +25,11 @@
ACE_RCSID(ace, Cached_Connect_Strategy_T, "$Id$")
- template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX>
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX>::ACE_Cached_Connect_Strategy_Ex
+#define ACE_T1 class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX
+#define ACE_T2 SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX
+
+template <ACE_T1>
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::ACE_Cached_Connect_Strategy_Ex
(CACHING_STRATEGY &caching_s,
ACE_Creation_Strategy<SVC_HANDLER> *cre_s,
ACE_Concurrency_Strategy<SVC_HANDLER> *con_s,
@@ -39,11 +42,11 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE
if (this->open (cre_s, con_s, rec_s) == -1)
ACE_ERROR ((LM_ERROR,
ASYS_TEXT ("%p\n"),
- ASYS_TEXT ("ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX>\n")));
+ ASYS_TEXT ("ACE_Cached_Connect_Strategy_Ex<ACE_T2>\n")));
}
-template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX>
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX>::~ACE_Cached_Connect_Strategy_Ex (void)
+template <ACE_T1>
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::~ACE_Cached_Connect_Strategy_Ex (void)
{
#if !defined (ACE_HAS_BROKEN_EXTENDED_TEMPLATES)
// Close down all cached service handlers.
@@ -60,8 +63,8 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE
#endif /* ACE_HAS_BROKEN_EXTENDED_TEMPLATES */
}
-template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX>::check_hint_i
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::check_hint_i
(SVC_HANDLER *&sh,
const ACE_PEER_CONNECTOR_ADDR &remote_addr,
ACE_Time_Value *timeout,
@@ -85,7 +88,7 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE
CONNECTION_CACHE_ENTRY *possible_entry = (CONNECTION_CACHE_ENTRY *) sh->recycling_act ();
// Check to see if the hint svc_handler has been closed down
- if (possible_entry->ext_id_.state () == ACE_Recyclable::CLOSED)
+ if (possible_entry->ext_id_.state () == ACE_RECYCLABLE_CLOSED)
{
// If close, decrement refcount
if (possible_entry->ext_id_.decrement () == 0)
@@ -105,7 +108,9 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE
// If hint is not closed, see if it is connected to the correct
// address and is recyclable
- else if (possible_entry->ext_id_ == remote_addr)
+ else if ((possible_entry->ext_id_.state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE ||
+ possible_entry->ext_id_.state () == ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE) &&
+ possible_entry->ext_id_.subject () == remote_addr)
{
// Hint successful
found = 1;
@@ -133,8 +138,8 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE
return 0;
}
-template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX>::find_or_create_svc_handler_i
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::find_or_create_svc_handler_i
(SVC_HANDLER *&sh,
const ACE_PEER_CONNECTOR_ADDR &remote_addr,
ACE_Time_Value *timeout,
@@ -149,7 +154,7 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE
// Try to find the address in the cache. Only if we don't find it
// do we create a new <SVC_HANDLER> and connect it with the server.
- if (this->connection_cache_.find (search_addr, entry) == -1)
+ if (this->find (search_addr, entry) == -1)
{
// Set the flag
found = 0;
@@ -198,14 +203,14 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE
}
-template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX>::cached_connect (SVC_HANDLER *&sh,
- const ACE_PEER_CONNECTOR_ADDR &remote_addr,
- ACE_Time_Value *timeout,
- const ACE_PEER_CONNECTOR_ADDR &local_addr,
- int reuse_addr,
- int flags,
- int perms)
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::cached_connect (SVC_HANDLER *&sh,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms)
{
// Actively establish the connection. This is a timed blocking
// connect.
@@ -260,8 +265,8 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE
}
-template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX>::connect_svc_handler_i
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::connect_svc_handler_i
(SVC_HANDLER *&sh,
const ACE_PEER_CONNECTOR_ADDR &remote_addr,
ACE_Time_Value *timeout,
@@ -310,7 +315,7 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE
// For all successful cases: mark the <svc_handler> in the cache
// as being <in_use>. Therefore recyclable is BUSY.
- entry->ext_id_.state (ACE_Recyclable::BUSY);
+ entry->ext_id_.state (ACE_RECYCLABLE_BUSY);
// And increment the refcount
entry->ext_id_.increment ();
@@ -319,22 +324,22 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE
}
-template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX>::cache_i (const void *recycling_act)
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::cache_i (const void *recycling_act)
{
// The wonders and perils of ACT
CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
// Mark the <svc_handler> in the cache as not being <in_use>.
// Therefore recyclable is IDLE.
- entry->ext_id_.state (ACE_Recyclable::IDLE_AND_PURGABLE);
+ entry->ext_id_.state (ACE_RECYCLABLE_IDLE_AND_PURGABLE);
return 0;
}
-template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX>::purge_i (const void *recycling_act)
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::purge_i (const void *recycling_act)
{
// The wonders and perils of ACT
CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
@@ -343,20 +348,20 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE
}
-template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX>::mark_as_closed_i (const void *recycling_act)
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::mark_as_closed_i (const void *recycling_act)
{
// The wonders and perils of ACT
CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
// Mark the <svc_handler> in the cache as CLOSED.
- entry->ext_id_.state (ACE_Recyclable::CLOSED);
+ entry->ext_id_.state (ACE_RECYCLABLE_CLOSED);
return 0;
}
-template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX>::cleanup_hint_i (const void *recycling_act)
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::cleanup_hint_i (const void *recycling_act)
{
// The wonders and perils of ACT
CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
@@ -366,7 +371,7 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE
// If the svc_handler state is closed and the refcount == 0, call
// close() on svc_handler.
- if (entry->ext_id_.state () == ACE_Recyclable::CLOSED &&
+ if (entry->ext_id_.state () == ACE_RECYCLABLE_CLOSED &&
refcount == 0)
{
entry->int_id_.first ()->recycler (0, 0);
@@ -377,18 +382,59 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE
return 0;
}
-template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX> int
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX>::purge_connections (void)
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::purge_connections (void)
{
return this->connection_cache_.purge ();
}
-template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX> CACHING_STRATEGY &
-ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX>::caching_strategy (void)
+template <ACE_T1> CACHING_STRATEGY &
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::caching_strategy (void)
{
return this->connection_cache_.caching_strategy ();
}
+template <ACE_T1> int
+ACE_Cached_Connect_Strategy_Ex<ACE_T2>::find (REFCOUNTED_HASH_RECYCLABLE_ADDRESS &search_addr,
+ ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>, ACE_Pair<SVC_HANDLER *, ATTRIBUTES> > *&entry)
+{
+ typedef ACE_Hash_Map_Bucket_Iterator<REFCOUNTED_HASH_RECYCLABLE_ADDRESS,
+ ACE_Pair<SVC_HANDLER *, ATTRIBUTES>,
+ ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
+ ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
+ ACE_Null_Mutex>
+ CONNECTION_CACHE_BUCKET_ITERATOR;
+
+ CONNECTION_CACHE_BUCKET_ITERATOR iterator (this->connection_cache_.map (),
+ search_addr);
+
+ CONNECTION_CACHE_BUCKET_ITERATOR end (this->connection_cache_.map (),
+ search_addr,
+ 1);
+
+ for (;
+ iterator != end;
+ ++iterator)
+ {
+ REFCOUNTED_HASH_RECYCLABLE_ADDRESS &addr = (*iterator).ext_id_;
+
+ if (addr.state () != ACE_RECYCLABLE_IDLE_AND_PURGABLE &&
+ addr.state () != ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE)
+ continue;
+
+ if (addr != search_addr)
+ continue;
+
+ entry = &(*iterator);
+ return 0;
+ }
+
+ return -1;
+}
+
ACE_ALLOC_HOOK_DEFINE(ACE_Cached_Connect_Strategy_Ex)
+#undef ACE_T1
+#undef ACE_T2
+
#endif /* CACHED_CONNECT_STRATEGY_T_C */
diff --git a/ace/Cached_Connect_Strategy_T.h b/ace/Cached_Connect_Strategy_T.h
index 31c3581ea48..2ab8f26ca35 100644
--- a/ace/Cached_Connect_Strategy_T.h
+++ b/ace/Cached_Connect_Strategy_T.h
@@ -57,28 +57,18 @@ public:
virtual ~ACE_Cached_Connect_Strategy_Ex (void);
// Destructor
- virtual int cached_connect (SVC_HANDLER *&sh,
- const ACE_PEER_CONNECTOR_ADDR &remote_addr,
- ACE_Time_Value *timeout,
- const ACE_PEER_CONNECTOR_ADDR &local_addr,
- int reuse_addr,
- int flags,
- int perms);
- // Connection of the svc_handler with the remote host.
- // This method also encapsulates the connection done with
- // auto_purging under the hood. If the connect failed due to the
- // process running out of file descriptors then, auto_purging of
- // some connections are done from the CONNECTION_CACHE. This frees
- // the descriptors which get used in the connect process and hence
- // the connect operation can succeed.
-
virtual int purge_connections (void);
// Explicit purging of connection entries from the connection cache.
// = Typedefs for managing the map
typedef ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>
REFCOUNTED_HASH_RECYCLABLE_ADDRESS;
- typedef ACE_Hash_Cache_Map_Manager<REFCOUNTED_HASH_RECYCLABLE_ADDRESS, SVC_HANDLER *, ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, CACHING_STRATEGY, ATTRIBUTES>
+ typedef ACE_Hash_Cache_Map_Manager<REFCOUNTED_HASH_RECYCLABLE_ADDRESS,
+ SVC_HANDLER *,
+ ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
+ ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
+ CACHING_STRATEGY,
+ ATTRIBUTES>
CONNECTION_CACHE;
typedef ACE_TYPENAME CONNECTION_CACHE::CACHE_ENTRY
CONNECTION_CACHE_ENTRY;
@@ -88,7 +78,13 @@ public:
VALUE;
// = Cleanup of the svc_handler.
- typedef ACE_Recyclable_Handler_Cleanup_Strategy<REFCOUNTED_HASH_RECYCLABLE_ADDRESS, ACE_Pair<SVC_HANDLER *, ATTRIBUTES>,ACE_Hash_Map_Manager_Ex<REFCOUNTED_HASH_RECYCLABLE_ADDRESS, ACE_Pair<SVC_HANDLER *, ATTRIBUTES>, ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>, MUTEX> >
+ typedef ACE_Recyclable_Handler_Cleanup_Strategy<REFCOUNTED_HASH_RECYCLABLE_ADDRESS,
+ ACE_Pair<SVC_HANDLER *, ATTRIBUTES>,
+ ACE_Hash_Map_Manager_Ex<REFCOUNTED_HASH_RECYCLABLE_ADDRESS,
+ ACE_Pair<SVC_HANDLER *, ATTRIBUTES>,
+ ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
+ ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
+ MUTEX> >
CLEANUP_STRATEGY;
typedef ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>
@@ -99,6 +95,10 @@ public:
protected:
+ int find (REFCOUNTED_HASH_RECYCLABLE_ADDRESS &search_addr,
+ ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>, ACE_Pair<SVC_HANDLER *, ATTRIBUTES> > *&entry);
+ // Find an idle handle.
+
virtual int purge_i (const void *recycling_act);
// Remove from cache (non-locking version).
@@ -114,34 +114,49 @@ protected:
// = Helpers
virtual int check_hint_i (SVC_HANDLER *&sh,
- const ACE_PEER_CONNECTOR_ADDR &remote_addr,
- ACE_Time_Value *timeout,
- const ACE_PEER_CONNECTOR_ADDR &local_addr,
- int reuse_addr,
- int flags,
- int perms,
- ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>, ACE_Pair<SVC_HANDLER *, ATTRIBUTES> > *&entry,
- int &found);
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms,
+ ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>, ACE_Pair<SVC_HANDLER *, ATTRIBUTES> > *&entry,
+ int &found);
virtual int find_or_create_svc_handler_i (SVC_HANDLER *&sh,
- const ACE_PEER_CONNECTOR_ADDR &remote_addr,
- ACE_Time_Value *timeout,
- const ACE_PEER_CONNECTOR_ADDR &local_addr,
- int reuse_addr,
- int flags,
- int perms,
- ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>, ACE_Pair<SVC_HANDLER *, ATTRIBUTES> > *&entry,
- int &found);
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms,
+ ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>, ACE_Pair<SVC_HANDLER *, ATTRIBUTES> > *&entry,
+ int &found);
virtual int connect_svc_handler_i (SVC_HANDLER *&sh,
- const ACE_PEER_CONNECTOR_ADDR &remote_addr,
- ACE_Time_Value *timeout,
- const ACE_PEER_CONNECTOR_ADDR &local_addr,
- int reuse_addr,
- int flags,
- int perms,
- int &found);
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms,
+ int &found);
+
+ virtual int cached_connect (SVC_HANDLER *&sh,
+ const ACE_PEER_CONNECTOR_ADDR &remote_addr,
+ ACE_Time_Value *timeout,
+ const ACE_PEER_CONNECTOR_ADDR &local_addr,
+ int reuse_addr,
+ int flags,
+ int perms);
+ // Connection of the svc_handler with the remote host. This method
+ // also encapsulates the connection done with auto_purging under the
+ // hood. If the connect failed due to the process running out of
+ // file descriptors then, auto_purging of some connections are done
+ // from the CONNECTION_CACHE. This frees the descriptors which get
+ // used in the connect process and hence the connect operation can
+ // succeed.
CONNECTION_CACHE connection_cache_;
// Table that maintains the cache of connected <SVC_HANDLER>s.
diff --git a/ace/Caching_Utility_T.cpp b/ace/Caching_Utility_T.cpp
index 47f2b34a362..8ae6be83539 100644
--- a/ace/Caching_Utility_T.cpp
+++ b/ace/Caching_Utility_T.cpp
@@ -77,8 +77,8 @@ ACE_Pair_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::clear_cac
return 0;
if (this->cleanup_strategy_->cleanup (container,
- key_to_remove,
- value_to_remove) == -1)
+ key_to_remove,
+ value_to_remove) == -1)
return -1;
}
@@ -115,6 +115,7 @@ ACE_Pair_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::minimum (
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
+
template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
ACE_Recyclable_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::ACE_Recyclable_Handler_Caching_Utility (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy,
int delete_cleanup_strategy)
@@ -173,8 +174,8 @@ ACE_Recyclable_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUT
return 0;
if (this->cleanup_strategy_->cleanup (container,
- key_to_remove,
- value_to_remove) == -1)
+ key_to_remove,
+ value_to_remove) == -1)
return -1;
}
@@ -204,8 +205,8 @@ ACE_Recyclable_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUT
// If the <min> entry isnt IDLE_AND_PURGABLE continue until you reach
// the first entry which can be purged. This is the minimum with
// which you will compare the rest of the purgable entries.
- if ((*iter).ext_id_.state () ==
- ACE_Recyclable::IDLE_AND_PURGABLE)
+ if ((*iter).ext_id_.state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE ||
+ (*iter).ext_id_.state () == ACE_RECYCLABLE_PURGABLE_BUT_NOT_IDLE)
{
if (found == 0)
{
@@ -229,6 +230,7 @@ ACE_Recyclable_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUT
}
////////////////////////////////////////////////////////////////////////////////
+
template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
ACE_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::ACE_Handler_Caching_Utility (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy,
int delete_cleanup_strategy)
diff --git a/ace/Cleanup_Strategies_T.cpp b/ace/Cleanup_Strategies_T.cpp
index 31be58692a0..b11d68b78bd 100644
--- a/ace/Cleanup_Strategies_T.cpp
+++ b/ace/Cleanup_Strategies_T.cpp
@@ -33,16 +33,18 @@ ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER>::cleanup (CONTAINER &container,
template <class KEY, class VALUE, class CONTAINER> int
ACE_Recyclable_Handler_Cleanup_Strategy<KEY, VALUE, CONTAINER>::cleanup (CONTAINER &container,
- KEY *key,
- VALUE *value)
+ KEY *key,
+ VALUE *)
{
- value->first ()->recycler (0, 0);
+ VALUE value;
- value->first ()->close ();
-
- if (container.unbind (*key) == -1)
+ if (container.unbind (*key, value) == -1)
return -1;
+ value.first ()->recycler (0, 0);
+
+ value.first ()->close ();
+
return 0;
}
diff --git a/ace/Strategies.h b/ace/Strategies.h
index 474c23503ac..c43ec639aa2 100644
--- a/ace/Strategies.h
+++ b/ace/Strategies.h
@@ -100,6 +100,10 @@ public:
virtual int cache (const void *recycling_act) = 0;
// Add to cache.
+ virtual int state (const void *recycling_act,
+ ACE_Recyclable_State new_state) = 0;
+ // Change state to <new_state>.
+
virtual int mark_as_closed (const void *recycling_act) = 0;
// Mark as closed.
@@ -114,36 +118,18 @@ protected:
class ACE_Export ACE_Recyclable
{
public:
- enum State
- {
- IDLE_AND_PURGABLE,
- // Idle and can be purged.
-
- IDLE_BUT_NOT_PURGABLE,
- // Idle but cannot be purged.
-
- BUSY = 2,
- // Busy (i.e., cannot be recycled or purged).
-
- CLOSED = 3,
- // Closed.
-
- UNKNOWN = 4
- // Unknown state.
- };
-
virtual ~ACE_Recyclable (void);
// Destructor.
// = Set/Get the recyclable bit
- State state (void) const;
- void state (State new_state);
+ ACE_Recyclable_State state (void) const;
+ void state (ACE_Recyclable_State new_state);
protected:
- ACE_Recyclable (State initial_state);
+ ACE_Recyclable (ACE_Recyclable_State initial_state);
// Protected constructor.
- State state_;
+ ACE_Recyclable_State state_;
// Our state.
};
diff --git a/ace/Strategies.i b/ace/Strategies.i
index 2d101275030..c3fd4d39651 100644
--- a/ace/Strategies.i
+++ b/ace/Strategies.i
@@ -14,7 +14,7 @@ ACE_Connection_Recycling_Strategy::ACE_Connection_Recycling_Strategy (void)
}
ACE_INLINE
-ACE_Recyclable::ACE_Recyclable (ACE_Recyclable::State initial_state)
+ACE_Recyclable::ACE_Recyclable (ACE_Recyclable_State initial_state)
: state_ (initial_state)
{
}
@@ -24,25 +24,25 @@ ACE_Recyclable::~ACE_Recyclable (void)
{
}
-ACE_INLINE ACE_Recyclable::State
+ACE_INLINE ACE_Recyclable_State
ACE_Recyclable::state (void) const
{
return this->state_;
}
-ACE_INLINE void
-ACE_Recyclable::state (ACE_Recyclable::State new_state)
+ACE_INLINE void
+ACE_Recyclable::state (ACE_Recyclable_State new_state)
{
this->state_ = new_state;
}
-ACE_INLINE
+ACE_INLINE
ACE_Hashable::ACE_Hashable (void)
: hash_value_ (0)
{
}
-ACE_INLINE
+ACE_INLINE
ACE_Hashable::~ACE_Hashable (void)
{
}
@@ -62,13 +62,13 @@ ACE_Hashable::hash (void) const
return this->hash_value_;
}
-ACE_INLINE
+ACE_INLINE
ACE_Refcountable::ACE_Refcountable (int refcount)
: refcount_ (refcount)
{
}
-ACE_INLINE
+ACE_INLINE
ACE_Refcountable::~ACE_Refcountable (void)
{
}
@@ -79,15 +79,14 @@ ACE_Refcountable::increment (void)
return ++this->refcount_;
}
-ACE_INLINE int
+ACE_INLINE int
ACE_Refcountable::decrement (void)
{
return --this->refcount_;
}
-ACE_INLINE int
+ACE_INLINE int
ACE_Refcountable::refcount (void) const
{
return this->refcount_;
}
-
diff --git a/ace/Strategies_T.cpp b/ace/Strategies_T.cpp
index 5bacb3db45e..b3b26979bf0 100644
--- a/ace/Strategies_T.cpp
+++ b/ace/Strategies_T.cpp
@@ -524,7 +524,7 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::check_hin
CONNECTION_MAP_ENTRY *possible_entry = (CONNECTION_MAP_ENTRY *) sh->recycling_act ();
// Check to see if the hint svc_handler has been closed down
- if (possible_entry->ext_id_.state () == ACE_Recyclable::CLOSED)
+ if (possible_entry->ext_id_.state () == ACE_RECYCLABLE_CLOSED)
{
// If close, decrement refcount
if (possible_entry->ext_id_.decrement () == 0)
@@ -544,7 +544,9 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::check_hin
// If hint is not closed, see if it is connected to the correct
// address and is recyclable
- else if (possible_entry->ext_id_ == remote_addr)
+ else if ((possible_entry->ext_id_.state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE ||
+ possible_entry->ext_id_.state () == ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE) &&
+ possible_entry->ext_id_.subject () == remote_addr)
{
// Hint successful
found = 1;
@@ -589,7 +591,7 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::find_or_c
// Try to find the address in the cache. Only if we don't find it
// do we create a new <SVC_HANDLER> and connect it with the server.
- if (this->connection_cache_.find (search_addr, entry) == -1)
+ if (this->find (search_addr, entry) == -1)
{
// Set the flag
found = 0;
@@ -796,7 +798,7 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::connect_s
// For all successful cases: mark the <svc_handler> in the cache
// as being <in_use>. Therefore recyclable is BUSY.
- entry->ext_id_.state (ACE_Recyclable::BUSY);
+ entry->ext_id_.state (ACE_RECYCLABLE_BUSY);
// And increment the refcount
entry->ext_id_.increment ();
@@ -823,7 +825,34 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cache_i (
// Mark the <svc_handler> in the cache as not being <in_use>.
// Therefore recyclable is IDLE.
- entry->ext_id_.state (ACE_Recyclable::IDLE_AND_PURGABLE);
+ entry->ext_id_.state (ACE_RECYCLABLE_IDLE_AND_PURGABLE);
+
+ return 0;
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::state (const void *recycling_act,
+ ACE_Recyclable_State new_state)
+{
+ // Synchronization is required here as the setting of the recyclable
+ // state must be done atomically with respect to other threads that
+ // are querying the cache.
+ ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1);
+
+ return this->state_i (recycling_act,
+ new_state);
+}
+
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::state_i (const void *recycling_act,
+ ACE_Recyclable_State new_state)
+{
+ // The wonders and perils of ACT
+ CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
+
+ // Mark the <svc_handler> in the cache as not being <in_use>.
+ // Therefore recyclable is IDLE.
+ entry->ext_id_.state (new_state);
return 0;
}
@@ -864,7 +893,7 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::mark_as_c
CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act;
// Mark the <svc_handler> in the cache as CLOSED.
- entry->ext_id_.state (ACE_Recyclable::CLOSED);
+ entry->ext_id_.state (ACE_RECYCLABLE_CLOSED);
return 0;
}
@@ -890,7 +919,7 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cleanup_h
// If the svc_handler state is closed and the refcount == 0, call
// close() on svc_handler.
- if (entry->ext_id_.state () == ACE_Recyclable::CLOSED &&
+ if (entry->ext_id_.state () == ACE_RECYCLABLE_CLOSED &&
refcount == 0)
{
entry->int_id_->recycler (0, 0);
@@ -919,6 +948,44 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::concurren
return this->concurrency_strategy_;
}
+template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int
+ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::find (REFCOUNTED_HASH_RECYCLABLE_ADDRESS &search_addr,
+ ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>, SVC_HANDLER *> *&entry)
+{
+ typedef ACE_Hash_Map_Bucket_Iterator<REFCOUNTED_HASH_RECYCLABLE_ADDRESS,
+ SVC_HANDLER *,
+ ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
+ ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
+ ACE_Null_Mutex>
+ CONNECTION_CACHE_BUCKET_ITERATOR;
+
+ CONNECTION_CACHE_BUCKET_ITERATOR iterator (this->connection_cache_,
+ search_addr);
+
+ CONNECTION_CACHE_BUCKET_ITERATOR end (this->connection_cache_,
+ search_addr,
+ 1);
+
+ for (;
+ iterator != end;
+ ++iterator)
+ {
+ REFCOUNTED_HASH_RECYCLABLE_ADDRESS &addr = (*iterator).ext_id_;
+
+ if (addr.state () != ACE_RECYCLABLE_IDLE_AND_PURGABLE &&
+ addr.state () != ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE)
+ continue;
+
+ if (addr != search_addr)
+ continue;
+
+ entry = &(*iterator);
+ return 0;
+ }
+
+ return -1;
+}
+
template <class SVC_HANDLER> void
ACE_DLL_Strategy<SVC_HANDLER>::dump (void) const
{
diff --git a/ace/Strategies_T.h b/ace/Strategies_T.h
index fdb2ad5ca96..b02ef9f0f73 100644
--- a/ace/Strategies_T.h
+++ b/ace/Strategies_T.h
@@ -649,17 +649,17 @@ public:
ACE_Refcounted_Hash_Recyclable (const T &t,
int refcount = 0,
- ACE_Recyclable::State state = ACE_Recyclable::UNKNOWN);
+ ACE_Recyclable_State state = ACE_RECYCLABLE_UNKNOWN);
// Constructor.
virtual ~ACE_Refcounted_Hash_Recyclable (void);
// Destructor
int operator== (const ACE_Refcounted_Hash_Recyclable<T> &rhs) const;
+ int operator!= (const ACE_Refcounted_Hash_Recyclable<T> &rhs) const;
// Compares two instances.
- int operator== (const T &rhs) const;
- // Compares two instances.
+ T &subject ();
protected:
u_long hash_i (void) const;
@@ -747,6 +747,10 @@ public:
virtual int cache (const void *recycling_act);
// Add to cache.
+ virtual int state (const void *recycling_act,
+ ACE_Recyclable_State new_state);
+ // Change state to <new_state>.
+
virtual int mark_as_closed (const void *recycling_act);
// Mark as closed.
@@ -782,12 +786,20 @@ public:
protected:
+ int find (REFCOUNTED_HASH_RECYCLABLE_ADDRESS &search_addr,
+ ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>, SVC_HANDLER *> *&entry);
+ // Find an idle handle.
+
virtual int purge_i (const void *recycling_act);
// Remove from cache (non-locking version).
virtual int cache_i (const void *recycling_act);
// Add to cache (non-locking version).
+ virtual int state_i (const void *recycling_act,
+ ACE_Recyclable_State new_state);
+ // Change state to <new_state> (non-locking version).
+
virtual int mark_as_closed_i (const void *recycling_act);
// Mark as closed (non-locking version).
diff --git a/ace/Strategies_T.i b/ace/Strategies_T.i
index dae0ed6bd10..4faf111f091 100644
--- a/ace/Strategies_T.i
+++ b/ace/Strategies_T.i
@@ -333,7 +333,7 @@ template <class T> ASYS_INLINE
ACE_Refcounted_Hash_Recyclable<T>::ACE_Refcounted_Hash_Recyclable (void)
: ACE_Refcountable (0),
ACE_Hashable (),
- ACE_Recyclable (ACE_Recyclable::UNKNOWN),
+ ACE_Recyclable (ACE_RECYCLABLE_UNKNOWN),
t_ ()
{
}
@@ -341,7 +341,7 @@ ACE_Refcounted_Hash_Recyclable<T>::ACE_Refcounted_Hash_Recyclable (void)
template <class T> ASYS_INLINE
ACE_Refcounted_Hash_Recyclable<T>::ACE_Refcounted_Hash_Recyclable (const T &t,
int refcount,
- ACE_Recyclable::State state)
+ ACE_Recyclable_State state)
: ACE_Refcountable (refcount),
ACE_Hashable (),
ACE_Recyclable (state),
@@ -360,24 +360,23 @@ ACE_Refcounted_Hash_Recyclable<T>::hash_i (void) const
return this->t_.hash ();
}
+template <class T> ASYS_INLINE T &
+ACE_Refcounted_Hash_Recyclable<T>::subject (void)
+{
+ return this->t_;
+}
+
template <class T> ASYS_INLINE int
ACE_Refcounted_Hash_Recyclable<T>::operator== (const ACE_Refcounted_Hash_Recyclable<T> &rhs) const
{
- if (this->state () != ACE_Recyclable::IDLE_AND_PURGABLE &&
- this->state () != ACE_Recyclable::IDLE_BUT_NOT_PURGABLE)
- return 0;
- else
- return this->t_ == rhs.t_;
+ return this->state () == rhs.state () &&
+ this->t_ == rhs.t_;
}
template <class T> ASYS_INLINE int
-ACE_Refcounted_Hash_Recyclable<T>::operator== (const T &rhs) const
+ACE_Refcounted_Hash_Recyclable<T>::operator!= (const ACE_Refcounted_Hash_Recyclable<T> &rhs) const
{
- if (this->state () != ACE_Recyclable::IDLE_AND_PURGABLE &&
- this->state () != ACE_Recyclable::IDLE_BUT_NOT_PURGABLE)
- return 0;
- else
- return this->t_ == rhs;
+ return !this->operator== (rhs);
}
template <class SVC_HANDLER> ASYS_INLINE int
diff --git a/ace/Svc_Handler.cpp b/ace/Svc_Handler.cpp
index 83262666129..6307f5765a6 100644
--- a/ace/Svc_Handler.cpp
+++ b/ace/Svc_Handler.cpp
@@ -300,6 +300,16 @@ ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::idle (u_long flags)
return this->close (flags);
}
+template <PR_ST_1, ACE_SYNCH_DECL> int
+ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::state (ACE_Recyclable_State new_state)
+{
+ if (this->recycler ())
+ return this->recycler ()->state (this->recycling_act_,
+ new_state);
+
+ return 0;
+}
+
template <PR_ST_1, ACE_SYNCH_DECL> void
ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::recycler (ACE_Connection_Recycling_Strategy *recycler,
const void *recycling_act)
diff --git a/ace/Svc_Handler.h b/ace/Svc_Handler.h
index a1251999404..36a341c45cc 100644
--- a/ace/Svc_Handler.h
+++ b/ace/Svc_Handler.h
@@ -71,6 +71,11 @@ public:
// instead of closing it. If the object does not have a recycler,
// it will be closed.
+ virtual int state (ACE_Recyclable_State new_state);
+ // Call this method if you want to change the state of the
+ // <Svc_Handler>. If the object does not have a recycler, this call
+ // will have no effect.
+
virtual void cleanup_hint (void);
// When the svc_handle is no longer needed around as a hint, call
// this method.
@@ -138,7 +143,7 @@ public:
public:
- // = The following methods are not suppose to be public.
+ // = The following methods are not suppose to be public.
// Because friendship is *not* inherited in C++, these methods have
// to be public.
@@ -238,7 +243,7 @@ protected:
size_t current_buffer_size_;
// Current size in bytes of the <Message_Queue> contents.
-
+
ACE_Time_Value next_timeout_;
// Timeout value used to control when the buffer is flushed.
diff --git a/tests/Cached_Accept_Conn_Test.cpp b/tests/Cached_Accept_Conn_Test.cpp
index 0370f541b0c..fc1849488d7 100644
--- a/tests/Cached_Accept_Conn_Test.cpp
+++ b/tests/Cached_Accept_Conn_Test.cpp
@@ -621,6 +621,7 @@ template class ACE_Hash_Map_Manager_Ex<ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_
template class ACE_Hash_Map_Iterator_Ex<ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>;
template class ACE_Hash_Map_Reverse_Iterator_Ex<ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>;
template class ACE_Hash_Map_Iterator_Base_Ex<ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Bucket_Iterator<ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>;
// = Caching_Strategy
template class ACE_Hash_Cache_Map_Manager<ADDR, Client_Svc_Handler *, H_KEY, C_KEYS, CACHING_STRATEGY, ATTRIBUTES>;
@@ -711,6 +712,7 @@ template class ACE_Recyclable_Handler_Caching_Utility<ADDR, CACHED_HANDLER, HASH
#pragma instantiate ACE_Hash_Map_Iterator_Ex<ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>
#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>
#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Bucket_Iterator<ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>
// = Caching_Strategy
#pragma instantiate ACE_Hash_Cache_Map_Manager<ADDR, Client_Svc_Handler *, H_KEY, C_KEYS, CACHING_STRATEGY, ATTRIBUTES>
diff --git a/tests/Cached_Conn_Test.cpp b/tests/Cached_Conn_Test.cpp
index c440b1b90ca..2f1662ba8ab 100644
--- a/tests/Cached_Conn_Test.cpp
+++ b/tests/Cached_Conn_Test.cpp
@@ -74,6 +74,7 @@ Svc_Handler::open (void *)
ASYS_TEXT ("opening Svc_Handler %d with handle %d\n"),
this,
this->peer ().get_handle ()));
+
return 0;
}
@@ -161,7 +162,8 @@ enum Caching_Strategy_Type
};
// Default number of clients/servers.
-static int default_iterations = 3000;
+static int default_iterations = 2000;
+static int listen_once = 1;
static int iterations = default_iterations;
static double purge_percentage = 20;
static Caching_Strategy_Type caching_strategy_type = ACE_ALL;
@@ -212,9 +214,8 @@ cached_connect (STRATEGY_CONNECTOR &con,
ASYS_TEXT ("connection failed")),
-1);
- // Svc_Handler is now idle, so mark it as such and let the cache
- // recycle it.
- svc_handler->idle (1);
+ // Reset Svc_Handler state.
+ svc_handler->state (ACE_RECYCLABLE_PURGABLE_BUT_NOT_IDLE);
return 0;
}
@@ -262,38 +263,54 @@ test_connection_management (CACHING_STRATEGY &caching_strategy)
&caching_connect_strategy,
&activation_strategy);
+ // If <listen_once> is true, only one Acceptor is used for the test.
+ ACCEPTOR listen_one_time_acceptor;
+ ACE_INET_Addr server_addr;
+
+ int result = listen_one_time_acceptor.open (ACE_sap_any_cast (const ACE_INET_Addr &));
+ ACE_ASSERT (result == 0);
+
+ result = listen_one_time_acceptor.acceptor ().get_local_addr (server_addr);
+ ACE_ASSERT (result == 0);
+
for (int i = 1; i <= iterations; ++i)
{
ACE_DEBUG ((LM_DEBUG,
ASYS_TEXT ("iteration %d\n"),
i));
- // Acceptor
- ACCEPTOR acceptor;
- ACE_INET_Addr server_addr;
-
- // Bind acceptor to any port and then find out what the port
- // was.
+ // If <listen_once> is false, one Acceptor is used for every
+ // iteration.
+ ACCEPTOR listen_multiple_times_acceptor;
- if (acceptor.open (ACE_sap_any_cast (const ACE_INET_Addr &)) == -1)
- {
- out_of_sockets_handler ();
- continue;
- }
+ ACCEPTOR &acceptor = listen_once ?
+ listen_one_time_acceptor :
+ listen_multiple_times_acceptor;
- if (acceptor.acceptor ().get_local_addr (server_addr) == -1)
+ if (!listen_once)
{
- ACE_ERROR ((LM_ERROR,
- ASYS_TEXT ("%p\n"),
- ASYS_TEXT ("get_local_addr")));
- ACE_ASSERT (0);
+ // Bind acceptor to any port and then find out what the port
+ // was.
+ if (acceptor.open (ACE_sap_any_cast (const ACE_INET_Addr &)) == -1)
+ {
+ out_of_sockets_handler ();
+ continue;
+ }
+
+ if (acceptor.acceptor ().get_local_addr (server_addr) == -1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("%p\n"),
+ ASYS_TEXT ("get_local_addr")));
+ ACE_ASSERT (0);
+ }
+
+ if (debug)
+ ACE_DEBUG ((LM_DEBUG,
+ ASYS_TEXT ("starting server at port %d\n"),
+ server_addr.get_port_number ()));
}
- if (debug)
- ACE_DEBUG ((LM_DEBUG,
- ASYS_TEXT ("starting server at port %d\n"),
- server_addr.get_port_number ()));
-
// Run the cached blocking test.
int result = cached_connect (strategy_connector,
server_addr);
@@ -363,7 +380,7 @@ test_caching_strategy_type (void)
int
parse_args (int argc, char *argv[])
{
- ACE_Get_Opt get_opt (argc, argv, "i:p:c:d");
+ ACE_Get_Opt get_opt (argc, argv, "l:i:p:c:d");
int cc;
@@ -373,6 +390,9 @@ parse_args (int argc, char *argv[])
case 'd':
debug = 1;
break;
+ case 'l':
+ listen_once = atoi (get_opt.optarg);
+ break;
case 'i':
iterations = atoi (get_opt.optarg);
break;
@@ -399,6 +419,7 @@ parse_args (int argc, char *argv[])
ASYS_TEXT ("usage: %s ")
ASYS_TEXT ("[-c (caching strategy: lru / lfu / fifo / null [default = all])] ")
ASYS_TEXT ("[-i (iterations)] ")
+ ASYS_TEXT ("[-l (listen once)] ")
ASYS_TEXT ("[-d (addition debugging output)] ")
ASYS_TEXT ("[-p (purge percent)] "),
argv[0]));
@@ -417,6 +438,13 @@ main (int argc,
if (result != 0)
return result;
+ if (iterations == default_iterations &&
+ listen_once)
+ {
+ default_iterations *= 2;
+ iterations = default_iterations;
+ }
+
// Start the test only if options are valid.
ACE_START_TEST (ASYS_TEXT ("Cached_Conn_Test"));
@@ -517,6 +545,7 @@ template class ACE_Hash_Map_Manager_Ex<ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_
template class ACE_Hash_Map_Iterator_Ex<ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>;
template class ACE_Hash_Map_Reverse_Iterator_Ex<ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>;
template class ACE_Hash_Map_Iterator_Base_Ex<ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Bucket_Iterator<ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>;
// = Caching_Strategy
template class ACE_Hash_Cache_Map_Manager<ADDR, Svc_Handler *, H_KEY, C_KEYS, CACHING_STRATEGY, ATTRIBUTES>;
@@ -601,6 +630,7 @@ template class ACE_Recyclable_Handler_Caching_Utility<ADDR, CACHED_HANDLER, HASH
#pragma instantiate ACE_Hash_Map_Iterator_Ex<ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>
#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>
#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Bucket_Iterator<ADDR, CACHED_HANDLER, H_KEY, C_KEYS, ACE_Null_Mutex>
// = Caching_Strategy
#pragma instantiate ACE_Hash_Cache_Map_Manager<ADDR, Svc_Handler *, H_KEY, C_KEYS, CACHING_STRATEGY, ATTRIBUTES>