From a38906e0a2ceae6e53bab0777e6bf0edf4e44c93 Mon Sep 17 00:00:00 2001 From: irfan Date: Tue, 13 Jul 1999 02:15:08 +0000 Subject: ChangeLogTag:Mon Jul 12 18:24:34 1999 Kirthika Parameswaran --- tests/Cached_Accept_Conn_Test.cpp | 742 ++++++++++++++++++++++++++++++++++++++ tests/Cached_Accept_Conn_Test.dsp | 298 +++++++++++++++ tests/Cached_Conn_Test.cpp | 4 +- 3 files changed, 1042 insertions(+), 2 deletions(-) create mode 100644 tests/Cached_Accept_Conn_Test.cpp create mode 100644 tests/Cached_Accept_Conn_Test.dsp (limited to 'tests') diff --git a/tests/Cached_Accept_Conn_Test.cpp b/tests/Cached_Accept_Conn_Test.cpp new file mode 100644 index 00000000000..908c552e75a --- /dev/null +++ b/tests/Cached_Accept_Conn_Test.cpp @@ -0,0 +1,742 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// tests +// +// = FILENAME +// Cached_Accept_Conn_Test.cpp +// +// = DESCRIPTION +// The test illustrates how the works by +// showing how you can cache connections on the client using +// different caching strategies. Also how connections can be purged +// explicitly and implicitly if needed from the connection cache +// maintained by the connector. The can also +// explicitly purge connections from the process CONNECTION CACHE on +// demand. +// +// = AUTHOR +// Kirthika Parameswaran +// +// ============================================================================ + +#ifndef CACHED_ACCEPT_CONNECTION_TEST +#define CACHED_ACCEPT_CONNECTION_TEST + +#include "test_config.h" + +#if defined(__GNUC__) && __GNUC__ == 2 && __GNUC_MINOR__ < 8 +#define ACE_HAS_BROKEN_EXTENDED_TEMPLATES +#endif /* __GNUC__ */ + +#include "ace/INET_Addr.h" +#include "ace/Strategies.h" +#include "ace/SOCK_Connector.h" +#include "ace/SOCK_Acceptor.h" +#include "ace/Svc_Handler.h" +#include "ace/SOCK_Stream.h" +#include "ace/Acceptor.h" +#include "ace/Connector.h" +#include "ace/Get_Opt.h" +#include "ace/Caching_Utility_T.h" +#include "ace/Cached_Connect_Strategy_T.h" + +#if defined(_MSC_VER) +#pragma warning(disable:4503) +#endif /* _MSC_VER */ + +ACE_RCSID(tests, Cached_Accept_Conn_Test, "$Id$") + +#if defined(__BORLANDC__) && __BORLANDC__ >= 0x0530 +USELIB("..\ace\aced.lib"); +//--------------------------------------------------------------------------- +#endif /* defined(__BORLANDC__) && __BORLANDC__ >= 0x0530 */ + +static int debug = 0; + +class Client_Svc_Handler : public ACE_Svc_Handler +{ +public: + + Client_Svc_Handler (ACE_Thread_Manager *t = 0); + int open (void *v = 0); + int close (u_long flags = 0); +}; + +Client_Svc_Handler::Client_Svc_Handler (ACE_Thread_Manager *t) + : ACE_Svc_Handler (t) +{ +} + +int +Client_Svc_Handler::open (void *) +{ + if (debug) + ACE_DEBUG ((LM_DEBUG, + ASYS_TEXT ("opening Client_Svc_Handler %d with handle %d\n"), + this, + this->peer ().get_handle ())); + return 0; +} + +int +Client_Svc_Handler::close (u_long flags) +{ + ACE_DEBUG ((LM_DEBUG, + ASYS_TEXT ("Closing Client_Svc_Handler %d with handle %d\n"), + this, + this->peer ().get_handle ())); + return ACE_Svc_Handler::close (flags); +} + +class Server_Svc_Handler : public ACE_Svc_Handler +{ +public: + + Server_Svc_Handler (ACE_Thread_Manager *t = 0); + int open (void *v = 0); +}; + +Server_Svc_Handler::Server_Svc_Handler (ACE_Thread_Manager *t) + : ACE_Svc_Handler (t) +{ +} + +int +Server_Svc_Handler::open (void *) +{ + if (debug) + ACE_DEBUG ((LM_DEBUG, + ASYS_TEXT ("opening Server_Svc_Handler %d with handle %d\n"), + this, + this->peer ().get_handle ())); + + int result = ACE_Reactor::instance ()->end_event_loop (); + ACE_ASSERT (result != 1); + ACE_UNUSED_ARG (result); + + return this->close (); +} + +typedef size_t ATTRIBUTES; +typedef ACE_Pair + CACHED_HANDLER; +typedef ACE_Refcounted_Hash_Recyclable + ADDR; +typedef ACE_Hash H_KEY; +typedef ACE_Equal_To C_KEYS; + +typedef ACE_Hash_Map_Manager_Ex + HASH_MAP; +typedef ACE_Hash_Map_Iterator_Ex + HASH_MAP_ITERATOR; +typedef ACE_Hash_Map_Reverse_Iterator_Ex + HASH_MAP_REVERSE_ITERATOR; + +typedef ACE_Recyclable_Handler_Cleanup_Strategy + CLEANUP_STRATEGY; +typedef ACE_Recyclable_Handler_Caching_Utility + CACHING_UTILITY; + +typedef ACE_LRU_Caching_Strategy + LRU_CACHING_STRATEGY; + +#if defined (ACE_HAS_BROKEN_EXTENDED_TEMPLATES) + +typedef LRU_CACHING_STRATEGY + CACHING_STRATEGY; + +#else + +typedef ACE_LFU_Caching_Strategy + LFU_CACHING_STRATEGY; +typedef ACE_FIFO_Caching_Strategy + FIFO_CACHING_STRATEGY; +typedef ACE_Null_Caching_Strategy + NULL_CACHING_STRATEGY; +typedef ACE_Caching_Strategy_Adapter + LRU_CACHING_STRATEGY_ADAPTER; +typedef ACE_Caching_Strategy_Adapter + LFU_CACHING_STRATEGY_ADAPTER; +typedef ACE_Caching_Strategy_Adapter + FIFO_CACHING_STRATEGY_ADAPTER; +typedef ACE_Caching_Strategy_Adapter + NULL_CACHING_STRATEGY_ADAPTER; +typedef ACE_Caching_Strategy + CACHING_STRATEGY; + +#endif /* ACE_HAS_BROKEN_EXTENDED_TEMPLATES */ + +typedef ACE_Strategy_Acceptor + ACCEPTOR; + +typedef ACE_Strategy_Connector + STRATEGY_CONNECTOR; + +typedef ACE_NOOP_Creation_Strategy + NULL_CREATION_STRATEGY; + +typedef ACE_NOOP_Concurrency_Strategy + NULL_ACTIVATION_STRATEGY; + +typedef ACE_Cached_Connect_Strategy_Ex + CACHED_CONNECT_STRATEGY; + +enum Caching_Strategy_Type +{ + ACE_LFU, + ACE_FIFO, + ACE_LRU, + ACE_NULL, + ACE_ALL +}; + +// Default number of clients/servers. +static int default_iterations = 3000; +static int iterations = default_iterations; +static double purge_percentage = 20; +static Caching_Strategy_Type caching_strategy_type = ACE_ALL; + +//==================================================================== + +template +class ACE_Cached_Accept_Strategy : public ACE_Accept_Strategy +{ +public: + + ACE_Cached_Accept_Strategy (CACHED_CONNECT_STRATEGY &caching_connect_strategy); + // Constructor. + + int open (const ACE_PEER_ACCEPTOR_ADDR &local_addr, + int restart = 0); + // Initialize the with . If the + // process runs out of descriptors, the unsed svc_handlers from the + // CONNECTION CACHE are removed. + + int accept_svc_handler (SVC_HANDLER *svc_handler); + // The default behavior delegates to the method of the + // PEER_ACCEPTOR. A check is made here for the process running out + // of file descriptors. If so, the CONNECTION CACHE is purged of + // some idle svc_handlers. + +protected: + + typedef ACE_Accept_Strategy ACCEPT_STRATEGY_BASE; + + int out_of_sockets_handler (void); + // Handler for removing cached connections. + + CACHED_CONNECT_STRATEGY &caching_connect_strategy_; +}; + +template +ACE_Cached_Accept_Strategy::ACE_Cached_Accept_Strategy (CACHED_CONNECT_STRATEGY &caching_connect_strategy) + : caching_connect_strategy_ (caching_connect_strategy) +{ +} + +template int +ACE_Cached_Accept_Strategy::open (const ACE_PEER_ACCEPTOR_ADDR &local_addr, + int restart) +{ + int result = ACCEPT_STRATEGY_BASE::open (local_addr, + restart); + + if (result == 0) + return result; + + // If the error occured due to the fact that the file descriptor + // limit was exhausted, then purge the connection cache of some + // entries. + result = this->out_of_sockets_handler (); + if (result == -1) + return -1; + + // If we are able to purge, try again. + return ACCEPT_STRATEGY_BASE::open (local_addr, restart); +} + +template int +ACE_Cached_Accept_Strategy::accept_svc_handler (SVC_HANDLER *svc_handler) +{ + // Note: The base class method isnt called since it closes the + // svc_handler on error which we want to avoid as we are trying to + // accept after purging. + + // Try to find out if the implementation of the reactor that we are + // using requires us to reset the event association for the newly + // created handle. This is because the newly created handle will + // inherit the properties of the listen handle, including its event + // associations. + int reset_new_handle = this->reactor_->uses_event_associations (); + + int result = this->acceptor_.accept (svc_handler->peer (), // stream + 0, // remote address + 0, // timeout + 1, // restart + reset_new_handle // reset new handler + ); + if (result == 0) + return result; + + // If the error occured due to teh fact that the file descriptor + // limit was exhausted, then purge the connection cache of some + // entries. + result = this->out_of_sockets_handler (); + if (result == 0) + { + return this->acceptor_.accept (svc_handler->peer (), // stream + 0, // remote address + 0, // timeout + 1, // restart + reset_new_handle // reset new handler + ); + } + + // Close down handler to avoid memory leaks. + svc_handler->close (0); + return result; +} + +template int +ACE_Cached_Accept_Strategy::out_of_sockets_handler (void) +{ + // ENOBUFS had to be checked on NT while ENOENT check had to be + // added for Solaris + Linux. + if (errno == EMFILE || errno == ENOBUFS || errno == ENOENT) + { + // Close connections which are cached by explicitly purging the + // connection cache maintained by the connector. + ACE_DEBUG ((LM_DEBUG, "Purging connections from Connection Cache...\n")); + + return this->caching_connect_strategy_.purge_connections (purge_percentage); + } + + return -1; +} + +typedef ACE_Cached_Accept_Strategy + CACHED_ACCEPT_STRATEGY; + +static int +cached_connect (STRATEGY_CONNECTOR &con, + const ACE_INET_Addr &server_addr) +{ + // This will make sure we get the host information correct. + ACE_INET_Addr remote_addr (server_addr.get_port_number (), + ACE_DEFAULT_SERVER_HOST); + + // Perform a blocking connect to the server using the Strategy + // Connector with a connection caching strategy. + Client_Svc_Handler *svc_handler = 0; + int result = con.connect (svc_handler, + remote_addr); + if (result == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ASYS_TEXT ("%p\n"), + 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); + + return 0; +} + +static void +server (void) +{ + ACE_Reactor::instance ()->reset_event_loop (); + + int result = ACE_Reactor::instance ()->run_event_loop (); + ACE_ASSERT (result != 1); + ACE_UNUSED_ARG (result); +} + +static void +test_connection_management (CACHING_STRATEGY &caching_strategy) +{ + // Configure the Strategy Connector with a strategy that caches + // connection. + CACHED_CONNECT_STRATEGY caching_connect_strategy (caching_strategy); + + NULL_CREATION_STRATEGY creation_strategy; + NULL_ACTIVATION_STRATEGY activation_strategy; + + STRATEGY_CONNECTOR strategy_connector (0, + &creation_strategy, + &caching_connect_strategy, + &activation_strategy); + + for (int i = 1; i <= iterations; ++i) + { + ACE_DEBUG ((LM_DEBUG, + ASYS_TEXT ("iteration %d\n"), + i)); + + // Connect strategy is required by the . + CACHED_ACCEPT_STRATEGY cached_accept_strategy (caching_connect_strategy); + + // Acceptor + ACCEPTOR acceptor; + ACE_INET_Addr server_addr; + + // Bind acceptor to any port and then find out what the port + // was. + if (acceptor.open (ACE_sap_any_cast (const ACE_INET_Addr &), + ACE_Reactor::instance (), + 0, + &cached_accept_strategy) == -1) + { + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p\n"), + ASYS_TEXT ("open"))); + ACE_ASSERT (0); + } + + 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 ())); + + // Run the cached blocking test. + int result = cached_connect (strategy_connector, + server_addr); + ACE_ASSERT (result != -1); + + server (); + } +} + +#if defined (ACE_HAS_BROKEN_EXTENDED_TEMPLATES) + +void +test_caching_strategy_type (void) +{ + ACE_DEBUG ((LM_DEBUG, "\nLRU_Caching_Strategy\n\n")); + CACHING_STRATEGY caching_strategy; + caching_strategy.purge_percent (purge_percentage); + test_connection_management (caching_strategy); +} + +#else + +void +test_caching_strategy_type (void) +{ + CACHING_STRATEGY *caching_strategy = 0; + + switch (caching_strategy_type) + { + case ACE_NULL: + ACE_DEBUG ((LM_DEBUG, "\nNull_Caching_Strategy\n\n")); + ACE_NEW (caching_strategy, + NULL_CACHING_STRATEGY_ADAPTER); + break; + + case ACE_LRU: + ACE_DEBUG ((LM_DEBUG, "\nLRU_Caching_Strategy\n\n")); + ACE_NEW (caching_strategy, + LRU_CACHING_STRATEGY_ADAPTER); + break; + + case ACE_LFU: + ACE_DEBUG ((LM_DEBUG, "\nLFU_Caching_Strategy\n\n")); + ACE_NEW (caching_strategy, + LFU_CACHING_STRATEGY_ADAPTER); + break; + + case ACE_FIFO: + ACE_DEBUG ((LM_DEBUG, "\nFIFO_Caching_Strategy\n\n")); + ACE_NEW (caching_strategy, + FIFO_CACHING_STRATEGY_ADAPTER); + break; + + case ACE_ALL: // Just to remove warnings! + break; + } + + caching_strategy->purge_percent (purge_percentage); + test_connection_management (*caching_strategy); + delete caching_strategy; +} + +#endif /* ACE_HAS_BROKEN_EXTENDED_TEMPLATES */ + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opt (argc, argv, "i:p:c:d"); + + int cc; + + while ((cc = get_opt ()) != -1) + switch (cc) + { + case 'd': + debug = 1; + break; + case 'i': + iterations = atoi (get_opt.optarg); + break; + case 'p': + purge_percentage = atoi (get_opt.optarg); + break; + case 'c': + // Note that if null caching strategy is used then this test + // will fail if the number of servers exceed number of open + // files allowed for the process. + if (ACE_OS::strcmp (get_opt.optarg, "null") == 0) + caching_strategy_type = ACE_NULL; + if (ACE_OS::strcmp (get_opt.optarg, "lru") == 0) + caching_strategy_type = ACE_LRU; + if (ACE_OS::strcmp (get_opt.optarg, "lfu") == 0) + caching_strategy_type = ACE_LFU; + if (ACE_OS::strcmp (get_opt.optarg, "fifo") == 0) + caching_strategy_type = ACE_FIFO; + break; + case '?': + case 'h': + default: + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("usage: %s ") + ASYS_TEXT ("[-t (timeout)] ") + ASYS_TEXT ("[-c (caching strategy: lru / lfu / fifo / null [default = all])] ") + ASYS_TEXT ("[-i (iterations)] ") + ASYS_TEXT ("[-d (addition debugging output)] ") + ASYS_TEXT ("[-p (purge percent)] "), + argv[0])); + return -1; + } + + return 0; +} + +int +main (int argc, + ASYS_TCHAR *argv[]) +{ + // Validate options. + int result = parse_args (argc, argv); + if (result != 0) + return result; + + // Start the test only if options are valid. + ACE_START_TEST (ASYS_TEXT ("Cached_Accept_Conn_Test")); + + // Remove the extra debugging attributes from Log_Msg output. + ACE_LOG_MSG->clr_flags (ACE_Log_Msg::VERBOSE_LITE); + + // Do we need to test all the strategies. Note, that the less + // useful null strategy is ignored in this case. + if (caching_strategy_type == ACE_ALL) + { + caching_strategy_type = ACE_LRU; + test_caching_strategy_type (); + + // Default iterations are too many; we the user hasn't specified + // otherwise, we'll shrink the iterations for LFU and FIFO. + if (iterations == default_iterations) + iterations = default_iterations / 100; + + caching_strategy_type = ACE_LFU; + test_caching_strategy_type (); + + caching_strategy_type = ACE_FIFO; + test_caching_strategy_type (); + } + else + { + test_caching_strategy_type (); + } + + ACE_LOG_MSG->set_flags (ACE_Log_Msg::VERBOSE_LITE); + ACE_END_TEST; + return 0; +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class ACE_Svc_Handler; +template class ACE_Refcounted_Hash_Recyclable; +template class ACE_NOOP_Creation_Strategy; +template class ACE_Concurrency_Strategy; +template class ACE_Connect_Strategy; +template class ACE_Connector; +template class ACE_Creation_Strategy; +template class ACE_Hash_Map_Entry; +template class ACE_Hash; +template class ACE_Equal_To; +template class ACE_Hash_Map_Manager; +template class ACE_Hash_Map_Manager_Ex; +template class ACE_Hash_Map_Iterator_Base_Ex; +template class ACE_Hash_Map_Iterator; +template class ACE_Hash_Map_Iterator_Ex; +template class ACE_Hash_Map_Reverse_Iterator; +template class ACE_Hash_Map_Reverse_Iterator_Ex; +template class ACE_Map_Entry *>; +template class ACE_Map_Manager *, ACE_SYNCH_RW_MUTEX>; +template class ACE_Map_Iterator_Base *, ACE_SYNCH_RW_MUTEX>; +template class ACE_Map_Iterator *, ACE_SYNCH_RW_MUTEX>; +template class ACE_Map_Reverse_Iterator *, ACE_SYNCH_RW_MUTEX>; +template class ACE_NOOP_Concurrency_Strategy; +template class ACE_Recycling_Strategy; +template class ACE_Strategy_Connector; +template class ACE_Svc_Tuple; + +template class ACE_Strategy_Acceptor; +template class ACE_Acceptor; + +template class ACE_Pair; +template class ACE_Reference_Pair; +template class ACE_Hash_Map_Entry; + +template class ACE_Hash_Map_Manager; +template class ACE_Hash_Map_Iterator; +template class ACE_Hash_Map_Reverse_Iterator; +template class ACE_Hash_Map_Manager_Ex; +template class ACE_Hash_Map_Iterator_Ex; +template class ACE_Hash_Map_Reverse_Iterator_Ex; +template class ACE_Hash_Map_Iterator_Base_Ex; + +template class ACE_Hash_Map_Manager; +template class ACE_Hash_Map_Iterator; +template class ACE_Hash_Map_Reverse_Iterator; +template class ACE_Hash_Map_Manager_Ex; +template class ACE_Hash_Map_Iterator_Ex; +template class ACE_Hash_Map_Reverse_Iterator_Ex; +template class ACE_Hash_Map_Iterator_Base_Ex; + +// = Caching_Strategy +template class ACE_Hash_Cache_Map_Manager; + +template class ACE_LRU_Caching_Strategy; + +#if !defined (ACE_HAS_BROKEN_EXTENDED_TEMPLATES) + +template class ACE_Caching_Strategy; +template class ACE_LFU_Caching_Strategy; +template class ACE_FIFO_Caching_Strategy; +template class ACE_Null_Caching_Strategy; + +template class ACE_Caching_Strategy_Adapter; +template class ACE_Caching_Strategy_Adapter; +template class ACE_Caching_Strategy_Adapter; +template class ACE_Caching_Strategy_Adapter; + +template class ACE_Cache_Map_Manager; +template class ACE_Cache_Map_Iterator; +template class ACE_Cache_Map_Reverse_Iterator; + +#else + +template class ACE_Cache_Map_Manager; + +#endif /* ACE_HAS_BROKEN_EXTENDED_TEMPLATES */ + +template class ACE_Cached_Connect_Strategy_Ex; +template class ACE_Cached_Connect_Strategy; + +template class ACE_Cleanup_Strategy; +template class ACE_Recyclable_Handler_Cleanup_Strategy; +template class ACE_Recyclable_Handler_Caching_Utility; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Svc_Handler +#pragma instantiate ACE_Refcounted_Hash_Recyclable +#pragma instantiate ACE_NOOP_Creation_Strategy +#pragma instantiate ACE_Concurrency_Strategy +#pragma instantiate ACE_Connect_Strategy +#pragma instantiate ACE_Connector +#pragma instantiate ACE_Creation_Strategy +#pragma instantiate ACE_Hash_Map_Entry +#pragma instantiate ACE_Hash +#pragma instantiate ACE_Equal_To +#pragma instantiate ACE_Hash_Map_Manager +#pragma instantiate ACE_Hash_Map_Manager_Ex +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex +#pragma instantiate ACE_Hash_Map_Iterator +#pragma instantiate ACE_Hash_Map_Iterator_Ex +#pragma instantiate ACE_Hash_Map_Reverse_Iterator +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex +#pragma instantiate ACE_Map_Entry *> +#pragma instantiate ACE_Map_Manager *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Iterator_Base *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Iterator *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Reverse_Iterator *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_NOOP_Concurrency_Strategy +#pragma instantiate ACE_Recycling_Strategy +#pragma instantiate ACE_Strategy_Connector +#pragma instantiate ACE_Svc_Tuple + +#pragma instantiate ACE_Strategy_Acceptor +#pragma instantiate ACE_Acceptor + +#pragma instantiate ACE_Pair +#pragma instantiate ACE_Reference_Pair +#pragma instantiate ACE_Hash_Map_Entry + +#pragma instantiate ACE_Hash_Map_Manager +#pragma instantiate ACE_Hash_Map_Iterator +#pragma instantiate ACE_Hash_Map_Reverse_Iterator +#pragma instantiate ACE_Hash_Map_Manager_Ex +#pragma instantiate ACE_Hash_Map_Iterator_Ex +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex + +#pragma instantiate ACE_Hash_Map_Manager +#pragma instantiate ACE_Hash_Map_Iterator +#pragma instantiate ACE_Hash_Map_Reverse_Iterator +#pragma instantiate ACE_Hash_Map_Manager_Ex +#pragma instantiate ACE_Hash_Map_Iterator_Ex +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex + +// = Caching_Strategy +#pragma instantiate ACE_Hash_Cache_Map_Manager + +#pragma instantiate ACE_LRU_Caching_Strategy + +#if !defined (ACE_HAS_BROKEN_EXTENDED_TEMPLATES) + +#pragma instantiate ACE_Caching_Strategy +#pragma instantiate ACE_LFU_Caching_Strategy +#pragma instantiate ACE_FIFO_Caching_Strategy +#pragma instantiate ACE_Null_Caching_Strategy + +#pragma instantiate ACE_Caching_Strategy_Adapter +#pragma instantiate ACE_Caching_Strategy_Adapter +#pragma instantiate ACE_Caching_Strategy_Adapter +#pragma instantiate ACE_Caching_Strategy_Adapter + +#pragma instantiate ACE_Cache_Map_Manager +#pragma instantiate ACE_Cache_Map_Iterator +#pragma instantiate ACE_Cache_Map_Reverse_Iterator + +#else + +#pragma instantiate ACE_Cache_Map_Manager + +#endif /* ACE_HAS_BROKEN_EXTENDED_TEMPLATES */ + +#pragma instantiate ACE_Cached_Connect_Strategy_Ex +#pragma instantiate ACE_Cached_Connect_Strategy + +#pragma instantiate ACE_Cleanup_Strategy +#pragma instantiate ACE_Recyclable_Handler_Cleanup_Strategy +#pragma instantiate ACE_Recyclable_Handler_Caching_Utility + +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + +#endif /* CACHED_CONNECT_TEST */ diff --git a/tests/Cached_Accept_Conn_Test.dsp b/tests/Cached_Accept_Conn_Test.dsp new file mode 100644 index 00000000000..2464e70bf6e --- /dev/null +++ b/tests/Cached_Accept_Conn_Test.dsp @@ -0,0 +1,298 @@ +# Microsoft Developer Studio Project File - Name="Cached_Accept_Conn_Test" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 +# TARGTYPE "Win32 (ALPHA) Console Application" 0x0603 + +CFG=Cached_Accept_Conn_Test - Win32 PharLap ETS Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Cached_Accept_Conn_Test.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Cached_Accept_Conn_Test.mak" CFG="Cached_Accept_Conn_Test - Win32 PharLap ETS Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Cached_Accept_Conn_Test - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE "Cached_Accept_Conn_Test - Win32 Alpha Debug" (based on "Win32 (ALPHA) Console Application") +!MESSAGE "Cached_Accept_Conn_Test - Win32 PharLap ETS Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "Cached_Accept_Conn_Test - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir ".\Cached_Accept_Conn_Test\Debug" +# PROP BASE Intermediate_Dir ".\Cached_Accept_Conn_Test\Debug" +# PROP BASE Target_Dir ".\Cached_Accept_Conn_Test" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "." +# PROP Intermediate_Dir ".\DLL\Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir ".\Cached_Accept_Conn_Test" +CPP=cl.exe +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FD /c +# SUBTRACT CPP /YX +RSC=rc.exe +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 +# ADD LINK32 aced.lib /nologo /subsystem:console /debug /machine:I386 /libpath:"..\ace" + +!ELSEIF "$(CFG)" == "Cached_Accept_Conn_Test - Win32 Alpha Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Cached_Accept_Conn_Test\Alpha Debug" +# PROP BASE Intermediate_Dir "Cached_Accept_Conn_Test\Alpha Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "Cached_Accept_Conn_Test" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "Cached_Accept_Conn_Test" +CPP=cl.exe +# ADD BASE CPP /nologo /Gt0 /W3 /GX /Zi /Od /I "..\\ /D " WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /MTd /c +# ADD CPP /nologo /Gt0 /W3 /GX /Zi /Od /I "..\\ /D " WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /MDd /c +# SUBTRACT CPP /YX +RSC=rc.exe +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 aced.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /debug /machine:ALPHA /libpath:"..\ace" +# ADD LINK32 aced.lib /nologo /subsystem:console /debug /machine:ALPHA /libpath:"..\ace" + +!ELSEIF "$(CFG)" == "Cached_Accept_Conn_Test - Win32 PharLap ETS Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Cached_Accept_Conn_Test\PharLap ETS Debug" +# PROP BASE Intermediate_Dir "Cached_Accept_Conn_Test\PharLap ETS Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "Cached_Accept_Conn_Test" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "." +# PROP Intermediate_Dir ".\ETS_LIB\Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "Cached_Accept_Conn_Test" +CPP=cl.exe +# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FD /c +# SUBTRACT BASE CPP /YX +# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D ACE_HAS_DLL=0 /FD /c +# SUBTRACT CPP /YX +RSC=rc.exe +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 aced.lib /nologo /subsystem:console /debug /machine:I386 /libpath:"..\ace" +# ADD LINK32 acesd.lib /nologo /subsystem:console /debug /machine:I386 /out:"./Cached_Accept_Conn_Test_ETS.exe" /libpath:"..\ace" /ETS:tests_pharlap_msvc.lnk +# SUBTRACT LINK32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "Cached_Accept_Conn_Test - Win32 Debug" +# Name "Cached_Accept_Conn_Test - Win32 Alpha Debug" +# Name "Cached_Accept_Conn_Test - Win32 PharLap ETS Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90" +# Begin Source File + +SOURCE=.\Cached_Accept_Conn_Test.cpp + +!IF "$(CFG)" == "Cached_Accept_Conn_Test - Win32 Debug" + +!ELSEIF "$(CFG)" == "Cached_Accept_Conn_Test - Win32 Alpha Debug" + +DEP_CPP_Cached_Accept_Conn_=\ + "..\ace\Acceptor.cpp"\ + "..\ace\Acceptor.h"\ + "..\ace\Acceptor.i"\ + "..\ace\ACE.h"\ + "..\ace\ACE.i"\ + "..\ace\Addr.h"\ + "..\ace\Addr.i"\ + "..\ace\Atomic_Op.i"\ + "..\ace\Auto_Ptr.cpp"\ + "..\ace\Auto_Ptr.h"\ + "..\ace\Auto_Ptr.i"\ + "..\ace\config-win32-common.h"\ + "..\ace\config-win32.h"\ + "..\ace\config.h"\ + "..\ace\Cached_Accept_Connector.cpp"\ + "..\ace\Cached_Accept_Connector.h"\ + "..\ace\Cached_Accept_Connector.i"\ + "..\ace\Containers.cpp"\ + "..\ace\Containers.h"\ + "..\ace\Containers.i"\ + "..\ace\Dynamic.h"\ + "..\ace\Dynamic.i"\ + "..\ace\Event_Handler.h"\ + "..\ace\Event_Handler.i"\ + "..\ace\Free_List.cpp"\ + "..\ace\Free_List.h"\ + "..\ace\Free_List.i"\ + "..\ace\Get_Opt.h"\ + "..\ace\Get_Opt.i"\ + "..\ace\Handle_Set.h"\ + "..\ace\Handle_Set.i"\ + "..\ace\Hash_Map_Manager.cpp"\ + "..\ace\Hash_Map_Manager.h"\ + "..\ace\INET_Addr.h"\ + "..\ace\INET_Addr.i"\ + "..\ace\IO_Cntl_Msg.h"\ + "..\ace\IPC_SAP.h"\ + "..\ace\IPC_SAP.i"\ + "..\ace\Log_Msg.h"\ + "..\ace\Log_Priority.h"\ + "..\ace\Log_Record.h"\ + "..\ace\Log_Record.i"\ + "..\ace\Malloc.h"\ + "..\ace\Malloc.i"\ + "..\ace\Malloc_T.cpp"\ + "..\ace\Malloc_T.h"\ + "..\ace\Malloc_T.i"\ + "..\ace\Managed_Object.cpp"\ + "..\ace\Managed_Object.h"\ + "..\ace\Managed_Object.i"\ + "..\ace\Map_Manager.cpp"\ + "..\ace\Map_Manager.h"\ + "..\ace\Map_Manager.i"\ + "..\ace\Mem_Map.h"\ + "..\ace\Mem_Map.i"\ + "..\ace\Memory_Pool.h"\ + "..\ace\Memory_Pool.i"\ + "..\ace\Message_Block.h"\ + "..\ace\Message_Block.i"\ + "..\ace\Message_Queue.cpp"\ + "..\ace\Message_Queue.h"\ + "..\ace\Message_Queue.i"\ + "..\ace\Module.cpp"\ + "..\ace\Module.h"\ + "..\ace\Module.i"\ + "..\ace\Object_Manager.h"\ + "..\ace\Object_Manager.i"\ + "..\ace\OS.h"\ + "..\ace\OS.i"\ + "..\ace\Reactor.h"\ + "..\ace\Reactor.i"\ + "..\ace\Reactor_Impl.h"\ + "..\ace\Service_Config.h"\ + "..\ace\Service_Config.i"\ + "..\ace\Service_Object.h"\ + "..\ace\Service_Object.i"\ + "..\ace\Service_Types.h"\ + "..\ace\Service_Types.i"\ + "..\ace\Shared_Object.h"\ + "..\ace\Shared_Object.i"\ + "..\ace\Signal.h"\ + "..\ace\Signal.i"\ + "..\ace\SOCK.h"\ + "..\ace\SOCK.i"\ + "..\ace\SOCK_Acceptor.h"\ + "..\ace\SOCK_Acceptor.i"\ + "..\ace\SOCK_Cached_Accept_Connector.h"\ + "..\ace\SOCK_Cached_Accept_Connector.i"\ + "..\ace\SOCK_IO.h"\ + "..\ace\SOCK_IO.i"\ + "..\ace\SOCK_Stream.h"\ + "..\ace\SOCK_Stream.i"\ + "..\ace\SString.h"\ + "..\ace\SString.i"\ + "..\ace\Strategies.h"\ + "..\ace\Strategies_T.cpp"\ + "..\ace\Strategies_T.h"\ + "..\ace\Stream_Modules.cpp"\ + "..\ace\Stream_Modules.h"\ + "..\ace\Stream_Modules.i"\ + "..\ace\SV_Semaphore_Complex.h"\ + "..\ace\SV_Semaphore_Complex.i"\ + "..\ace\SV_Semaphore_Simple.h"\ + "..\ace\SV_Semaphore_Simple.i"\ + "..\ace\Svc_Conf_Tokens.h"\ + "..\ace\Svc_Handler.cpp"\ + "..\ace\Svc_Handler.h"\ + "..\ace\Svc_Handler.i"\ + "..\ace\Synch.h"\ + "..\ace\Synch.i"\ + "..\ace\Synch_Options.h"\ + "..\ace\Synch_T.cpp"\ + "..\ace\Synch_T.h"\ + "..\ace\Synch_T.i"\ + "..\ace\Task.h"\ + "..\ace\Task.i"\ + "..\ace\Task_T.cpp"\ + "..\ace\Task_T.h"\ + "..\ace\Task_T.i"\ + "..\ace\Thread.h"\ + "..\ace\Thread.i"\ + "..\ace\Thread_Manager.h"\ + "..\ace\Thread_Manager.i"\ + "..\ace\Time_Value.h"\ + "..\ace\Timer_Queue.h"\ + "..\ace\Timer_Queue_T.cpp"\ + "..\ace\Timer_Queue_T.h"\ + "..\ace\Timer_Queue_T.i"\ + "..\ace\Trace.h"\ + "..\ace\Version.h"\ + "..\ace\WFMO_Reactor.h"\ + "..\ace\WFMO_Reactor.i"\ + "..\ace\ws2tcpip.h"\ + ".\Cached_Accept_Conn_Test.h"\ + ".\test_config.h"\ + +NODEP_CPP_Cached_Accept_Conn_=\ + "..\ace\stdcpp.h"\ + + +!ELSEIF "$(CFG)" == "Cached_Accept_Conn_Test - Win32 PharLap ETS Debug" + +!ENDIF + +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" +# Begin Source File + +SOURCE=.\Cached_Accept_Conn_Test.h +# End Source File +# Begin Source File + +SOURCE=.\test_config.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/tests/Cached_Conn_Test.cpp b/tests/Cached_Conn_Test.cpp index 2f347caf26e..8bd911b21d0 100644 --- a/tests/Cached_Conn_Test.cpp +++ b/tests/Cached_Conn_Test.cpp @@ -264,7 +264,7 @@ test_connection_management (CACHING_STRATEGY &caching_strategy) &caching_connect_strategy, &activation_strategy); - for (int i = 0; i < iterations; ++i) + for (int i = 1; i <= iterations; ++i) { ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("iteration %d\n"), @@ -287,7 +287,7 @@ test_connection_management (CACHING_STRATEGY &caching_strategy) { ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), - ASYS_TEXT ("open"))); + ASYS_TEXT ("get_local_addr"))); ACE_ASSERT (0); } -- cgit v1.2.1