diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-11-23 02:09:14 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-11-23 02:09:14 +0000 |
commit | 1b9bf25ac6d0a926a880b6d4dbf65eafeb80e880 (patch) | |
tree | b0141174a0a992ad5b149d7285bc2ed976faf9a3 /tests | |
parent | ae1b0db791e7cbc52614cd135a8876f55c17c80f (diff) | |
download | ATCD-1b9bf25ac6d0a926a880b6d4dbf65eafeb80e880.tar.gz |
*** empty log message ***
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Priority_Reactor_Test.cpp | 5 | ||||
-rw-r--r-- | tests/Process_Strategy_Test.cpp | 93 | ||||
-rw-r--r-- | tests/Process_Strategy_Test.h | 19 | ||||
-rw-r--r-- | tests/tests.mdp | bin | 18946 -> 18681 bytes | |||
-rw-r--r-- | tests/version_tests/version_tests.mdp | bin | 164864 -> 164864 bytes |
5 files changed, 65 insertions, 52 deletions
diff --git a/tests/Priority_Reactor_Test.cpp b/tests/Priority_Reactor_Test.cpp index 9e2a3692a36..bb1cf5a4614 100644 --- a/tests/Priority_Reactor_Test.cpp +++ b/tests/Priority_Reactor_Test.cpp @@ -253,8 +253,9 @@ main (int argc, char *argv[]) } // Manage memory automagically. - auto_ptr<ACE_Select_Reactor> impl; + // Note: This ordering is very subtle... auto_ptr<ACE_Reactor> reactor; + auto_ptr<ACE_Select_Reactor> impl; if (opt_priority_reactor) { @@ -332,7 +333,7 @@ main (int argc, char *argv[]) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) running out of time, " - "probably due to failed connections.")); + "probably due to failed connections.\n")); } ACE_DEBUG ((LM_DEBUG, "(%P|%t) waiting for the children...\n")); diff --git a/tests/Process_Strategy_Test.cpp b/tests/Process_Strategy_Test.cpp index 3944dbadb44..3c111b8b2a1 100644 --- a/tests/Process_Strategy_Test.cpp +++ b/tests/Process_Strategy_Test.cpp @@ -51,8 +51,7 @@ // Define a <Strategy_Acceptor> that's parameterized by the // <Counting_Service>. -typedef ACE_Strategy_Acceptor <Counting_Service, ACE_SOCK_ACCEPTOR> - ACCEPTOR; +typedef ACE_Strategy_Acceptor <Counting_Service, ACE_SOCK_ACCEPTOR> ACCEPTOR; // Create an Options Singleton. typedef ACE_Singleton<Options, ACE_Null_Mutex> OPTIONS; @@ -61,14 +60,47 @@ typedef ACE_Singleton<Options, ACE_Null_Mutex> OPTIONS; static int connections = 0; // Use this to show down the process gracefully. +static void +connection_completed () +{ + // Increment connection counter + connections++; + + // If all connections have been serviced + if (connections == ACE_MAX_ITERATIONS + 1) + // Make sure that the event loop is interrupted + ACE_Reactor::instance()->wakeup_all_threads (); +} +// Have all connections been serviced? static int done (void) { - if (OPTIONS::instance ()->concurrency_type () == Options::PROCESS) - return connections == 1; - else - return connections == ACE_MAX_ITERATIONS + 1; + return connections == ACE_MAX_ITERATIONS + 1; +} + +// Constructor +Process_Strategy::Process_Strategy (size_t n_processes, + ACE_Event_Handler *acceptor, + ACE_Reactor *r, + int flags) + : ACE_Process_Strategy<Counting_Service> (n_processes, acceptor, r, flags) +{ +} + +// Overwrite the process creation method to include connection +// counting +int +Process_Strategy::activate_svc_handler (Counting_Service *svc_handler, + void *arg) +{ + // Call down to the base class + int result = ACE_Process_Strategy<Counting_Service>::activate_svc_handler (svc_handler, arg); + + // Connection is now complete + connection_completed (); + + return result; } ACE_File_Lock & @@ -93,11 +125,11 @@ Options::Options (void) : // Choose to use processes by default. #if !defined (ACE_LACKS_FORK) - concurrency_type_ (PROCESS) + concurrency_type_ (PROCESS) #elif defined (ACE_HAS_THREADS) - concurrency_type_ (THREAD) + concurrency_type_ (THREAD) #else - concurrency_type_ (REACTIVE) + concurrency_type_ (REACTIVE) #endif /* !ACE_LACKS_FORK */ { } @@ -164,8 +196,7 @@ Options::parse_args (int argc, char *argv[]) case Options::PROCESS: #if !defined (ACE_LACKS_FORK) ACE_NEW_RETURN (this->concurrency_strategy_, - ACE_Process_Strategy<Counting_Service> - (1, this, ACE_Reactor::instance()), + Process_Strategy (1, this, ACE_Reactor::instance()), -1); break; #else @@ -175,7 +206,7 @@ Options::parse_args (int argc, char *argv[]) #if defined (ACE_HAS_THREADS) ACE_NEW_RETURN (this->concurrency_strategy_, ACE_Thread_Strategy<Counting_Service> - (ACE_Thread_Manager::instance (), + (ACE_Thread_Manager::instance (), THR_NEW_LWP, 1), -1); break; @@ -191,13 +222,6 @@ Options::parse_args (int argc, char *argv[]) break; } -#if !defined (ACE_WIN32) && !defined (VXWORKS) - // Register to handle <SIGCHLD> when a child exits. - if (ACE_Reactor::instance ()->register_handler (SIGCHLD, this) == -1) - return -1; -#endif /* !defined (ACE_WIN32) && !defined (VXWORKS) */ - if (ACE_Reactor::instance ()->register_handler (SIGINT, this) == -1) - return -1; return 0; } @@ -213,28 +237,6 @@ Options::concurrency_type (Options::Concurrency_Type cs) this->concurrency_type_ = cs; } -// Reap child processes. - -int -Options::handle_signal (int signum, siginfo_t *, ucontext_t *) -{ - switch (signum) - { - case SIGCHLD: - pid_t pid; - - while ((pid = ACE_OS::waitpid (-1, 0, WNOHANG)) > 0) - continue; - break; - - case SIGINT: - ACE_Reactor::end_event_loop(); - break; - } - - return 0; -} - Counting_Service::Counting_Service (ACE_Thread_Manager *) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) creating the Counting_Service\n")); @@ -361,7 +363,7 @@ Counting_Service::handle_close (ACE_HANDLE, ACE_Reactor_Mask) { // Done with another connection. - connections++; + connection_completed (); // Call down to base class return ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>::handle_close (); @@ -532,15 +534,12 @@ main (int argc, char *argv[]) exit (-1); /* NOTREACHED */ case 0: - signal (SIGCHLD, SIG_IGN); + ACE_OS::signal (SIGCHLD, SIG_IGN); server (0); break; /* NOTREACHED */ default: client (&server_addr); - // Shutdown the server process. - if (ACE_OS::kill (pid, SIGINT) == 0) - ACE_OS::wait (); break; /* NOTREACHED */ } @@ -558,7 +557,7 @@ main (int argc, char *argv[]) ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n%a", "thread create failed")); // Wait for the threads to exit. - ACE_Thread_Manager::instance ()->wait (); + ACE_Thread_Manager::instance ()->wait (); #else ACE_ERROR ((LM_ERROR, "(%P|%t) only one thread may be run in a process on this platform\n%a", diff --git a/tests/Process_Strategy_Test.h b/tests/Process_Strategy_Test.h index 7556af9566d..7f8c9dcfcf7 100644 --- a/tests/Process_Strategy_Test.h +++ b/tests/Process_Strategy_Test.h @@ -65,6 +65,22 @@ protected: // Closing down }; +class Process_Strategy : public ACE_Process_Strategy<Counting_Service> +{ +public: + + // Constructor + Process_Strategy (size_t n_processes = 1, + ACE_Event_Handler *acceptor = 0, + ACE_Reactor * = 0, + int flags = 0); + + // Overwrite the process creation method to include connection + // counting + virtual int activate_svc_handler (Counting_Service *svc_handler, + void *arg = 0); +}; + class Options : public ACE_Event_Handler // = TITLE // Maintains the options for this program. @@ -99,9 +115,6 @@ public: ACE_Concurrency_Strategy <Counting_Service> *concurrency_strategy (void); // Returns the concurrency strategy. - virtual int handle_signal (int, siginfo_t *, ucontext_t *); - // Catch the SIGCHLD signal and reap the exiting child processes. - private: Concurrency_Type concurrency_type_; // Concurrency strategy that we're running. diff --git a/tests/tests.mdp b/tests/tests.mdp Binary files differindex 6413afe375e..04c8793eedd 100644 --- a/tests/tests.mdp +++ b/tests/tests.mdp diff --git a/tests/version_tests/version_tests.mdp b/tests/version_tests/version_tests.mdp Binary files differindex d7b2c9f922d..094f98e6fe6 100644 --- a/tests/version_tests/version_tests.mdp +++ b/tests/version_tests/version_tests.mdp |