summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-11-23 02:09:14 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-11-23 02:09:14 +0000
commit1b9bf25ac6d0a926a880b6d4dbf65eafeb80e880 (patch)
treeb0141174a0a992ad5b149d7285bc2ed976faf9a3
parentae1b0db791e7cbc52614cd135a8876f55c17c80f (diff)
downloadATCD-1b9bf25ac6d0a926a880b6d4dbf65eafeb80e880.tar.gz
*** empty log message ***
-rw-r--r--ace/Acceptor.cpp8
-rw-r--r--ace/Priority_Reactor.cpp8
-rw-r--r--ace/Strategies_T.cpp1
-rw-r--r--tests/Priority_Reactor_Test.cpp5
-rw-r--r--tests/Process_Strategy_Test.cpp93
-rw-r--r--tests/Process_Strategy_Test.h19
-rw-r--r--tests/tests.mdpbin18946 -> 18681 bytes
-rw-r--r--tests/version_tests/version_tests.mdpbin164864 -> 164864 bytes
8 files changed, 71 insertions, 63 deletions
diff --git a/ace/Acceptor.cpp b/ace/Acceptor.cpp
index 3f93a231775..53297383d74 100644
--- a/ace/Acceptor.cpp
+++ b/ace/Acceptor.cpp
@@ -257,14 +257,13 @@ template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::activate_svc_handler
(SVC_HANDLER *svc_handler)
{
- ACE_Trace::start_tracing ();
ACE_TRACE ("ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::activate_svc_handler");
int result = 0;
// See if we should enable non-blocking I/O on the <svc_handler>'s
// peer.
- if (ACE_BIT_ENABLED (this->flags_, ACE_NONBLOCK) != 0)
+ if (ACE_BIT_ENABLED (this->flags_, ACE_NONBLOCK))
{
if (svc_handler->peer ().enable (ACE_NONBLOCK) == -1)
result = -1;
@@ -273,13 +272,12 @@ ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::activate_svc_handler
else if (svc_handler->peer ().disable (ACE_NONBLOCK) == -1)
result = -1;
- if (svc_handler->open ((void *) this) == -1)
+ if (result == 0 && svc_handler->open ((void *) this) == -1)
result = -1;
-
+
if (result == -1)
svc_handler->close (0);
- ACE_Trace::stop_tracing ();
return result;
}
diff --git a/ace/Priority_Reactor.cpp b/ace/Priority_Reactor.cpp
index 29ec6a9550f..bd9d48ab12e 100644
--- a/ace/Priority_Reactor.cpp
+++ b/ace/Priority_Reactor.cpp
@@ -23,8 +23,8 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Priority_Reactor)
const int npriorities =
ACE_Event_Handler::HI_PRIORITY - ACE_Event_Handler::LO_PRIORITY + 1;
-ACE_INLINE
-void ACE_Priority_Reactor::init_bucket (void)
+ACE_INLINE void
+ACE_Priority_Reactor::init_bucket (void)
{
// Allocate enough space for all the handles.
// TODO: This can be wrong, maybe we should use other kind of
@@ -38,10 +38,6 @@ void ACE_Priority_Reactor::init_bucket (void)
int i;
for (i = 0; i < npriorities; ++i)
{
- this->bucket_[i] = 0;
- }
- for (i = 0; i < npriorities; ++i)
- {
ACE_NEW (this->bucket_[i], QUEUE (this->tuple_allocator_));
}
}
diff --git a/ace/Strategies_T.cpp b/ace/Strategies_T.cpp
index db904cc0552..cde17d72709 100644
--- a/ace/Strategies_T.cpp
+++ b/ace/Strategies_T.cpp
@@ -361,6 +361,7 @@ ACE_Reactive_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *svc_handl
if (result == -1)
svc_handler->close (0);
+
return result;
}
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
index 6413afe375e..04c8793eedd 100644
--- a/tests/tests.mdp
+++ b/tests/tests.mdp
Binary files differ
diff --git a/tests/version_tests/version_tests.mdp b/tests/version_tests/version_tests.mdp
index d7b2c9f922d..094f98e6fe6 100644
--- a/tests/version_tests/version_tests.mdp
+++ b/tests/version_tests/version_tests.mdp
Binary files differ