diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-06-21 21:18:43 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-06-21 21:18:43 +0000 |
commit | 4a64648a3f05d15cfffb693e24c76997d6a58423 (patch) | |
tree | d63d31d06a4549605f6a85d9719e1f84b2bd2e29 /examples | |
parent | f9438cf147b2b788b151f522cefe526d1a8e67c4 (diff) | |
download | ATCD-4a64648a3f05d15cfffb693e24c76997d6a58423.tar.gz |
*** empty log message ***
Diffstat (limited to 'examples')
-rw-r--r-- | examples/ASX/Message_Queue/Makefile | 2 | ||||
-rw-r--r-- | examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp | 16 | ||||
-rw-r--r-- | examples/Reactor/FIFO/Makefile | 171 | ||||
-rw-r--r-- | examples/Reactor/FIFO/client.cpp | 17 | ||||
-rw-r--r-- | examples/Reactor/FIFO/server.cpp | 80 | ||||
-rw-r--r-- | examples/Reactor/Makefile | 1 | ||||
-rw-r--r-- | examples/Reactor/Misc/notification.cpp | 70 | ||||
-rw-r--r-- | examples/Reactor/Misc/pingpong.cpp | 39 | ||||
-rw-r--r-- | examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.cpp | 1 | ||||
-rw-r--r-- | examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.i | 7 |
10 files changed, 355 insertions, 49 deletions
diff --git a/examples/ASX/Message_Queue/Makefile b/examples/ASX/Message_Queue/Makefile index f76ef41a74a..1c2146c05bd 100644 --- a/examples/ASX/Message_Queue/Makefile +++ b/examples/ASX/Message_Queue/Makefile @@ -11,7 +11,7 @@ BIN = buffer_stream \ bounded_buffer \ priority_buffer - + VLDLIBS = $(LDLIBS:%=%$(VAR)) BUILD = $(VBIN) diff --git a/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp b/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp index 0e7004584ee..9d54e0d00bf 100644 --- a/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp +++ b/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp @@ -6,7 +6,6 @@ // the fifo. The child reads from the ACE_FIFO and executes the more // command. - #include "ace/FIFO_Recv.h" #include "ace/FIFO_Send.h" @@ -14,9 +13,9 @@ #define EXEC_NAME "more" #define EXEC_COMMAND_ARG "more" -const char *FIFO_NAME = "/tmp/fifo"; +static const char *FIFO_NAME = "/tmp/fifo"; -int +static int do_child (ACE_FIFO_Recv &fifo_reader) { // Set child's stdin to read from the fifo. @@ -32,13 +31,14 @@ do_child (ACE_FIFO_Recv &fifo_reader) return 0; } -int -do_parent (const char fifo_name[], char input_filename[]) +static int +do_parent (const char fifo_name[], + char input_filename[]) { - int inputfd; + int inputfd; ACE_FIFO_Send fifo_sender (fifo_name, O_WRONLY | O_CREAT); - int len; - char buf[BUFSIZ]; + int len; + char buf[BUFSIZ]; if (fifo_sender.get_handle () == ACE_INVALID_HANDLE) return -1; diff --git a/examples/Reactor/FIFO/Makefile b/examples/Reactor/FIFO/Makefile new file mode 100644 index 00000000000..9de645b2846 --- /dev/null +++ b/examples/Reactor/FIFO/Makefile @@ -0,0 +1,171 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for testing the Reactor and FIFOs +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = client \ + server + +LSRC = $(addsuffix .cpp,$(BIN)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/client.o .shobj/client.so: client.cpp \ + $(WRAPPER_ROOT)/ace/FIFO_Send_Msg.h \ + $(WRAPPER_ROOT)/ace/FIFO_Send.h \ + $(WRAPPER_ROOT)/ace/FIFO.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/stdcpp.h \ + $(WRAPPER_ROOT)/ace/OS.i \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/FIFO.i \ + $(WRAPPER_ROOT)/ace/FIFO_Send.i \ + $(WRAPPER_ROOT)/ace/FIFO_Send_Msg.i +.obj/server.o .shobj/server.so: server.cpp \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/stdcpp.h \ + $(WRAPPER_ROOT)/ace/OS.i \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Shared_Object.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.i \ + $(WRAPPER_ROOT)/ace/Service_Object.i \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Thread.i \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Synch_T.i \ + $(WRAPPER_ROOT)/ace/Synch_T.cpp \ + $(WRAPPER_ROOT)/ace/Thread_Manager.i \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Containers.h \ + $(WRAPPER_ROOT)/ace/Containers.i \ + $(WRAPPER_ROOT)/ace/Containers.cpp \ + $(WRAPPER_ROOT)/ace/Signal.i \ + $(WRAPPER_ROOT)/ace/Service_Config.i \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.i \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue_T.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/Free_List.h \ + $(WRAPPER_ROOT)/ace/Free_List.i \ + $(WRAPPER_ROOT)/ace/Free_List.cpp \ + $(WRAPPER_ROOT)/ace/Timer_Queue_T.i \ + $(WRAPPER_ROOT)/ace/Timer_Queue_T.cpp \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/Addr.i \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/INET_Addr.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Reactor.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Asynch_IO.h \ + $(WRAPPER_ROOT)/ace/Timer_List.h \ + $(WRAPPER_ROOT)/ace/Timer_List_T.h \ + $(WRAPPER_ROOT)/ace/Timer_List_T.cpp \ + $(WRAPPER_ROOT)/ace/Timer_Heap.h \ + $(WRAPPER_ROOT)/ace/Timer_Heap_T.h \ + $(WRAPPER_ROOT)/ace/Timer_Heap_T.cpp \ + $(WRAPPER_ROOT)/ace/Timer_Wheel.h \ + $(WRAPPER_ROOT)/ace/Timer_Wheel_T.h \ + $(WRAPPER_ROOT)/ace/Timer_Wheel_T.cpp \ + $(WRAPPER_ROOT)/ace/High_Res_Timer.h \ + $(WRAPPER_ROOT)/ace/High_Res_Timer.i \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.i \ + $(WRAPPER_ROOT)/ace/Malloc_T.cpp \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.i \ + $(WRAPPER_ROOT)/ace/Memory_Pool.i \ + $(WRAPPER_ROOT)/ace/Message_Block.i \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies_T.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Hash_Map_Manager.h \ + $(WRAPPER_ROOT)/ace/Hash_Map_Manager.cpp \ + $(WRAPPER_ROOT)/ace/Strategies_T.cpp \ + $(WRAPPER_ROOT)/ace/Message_Queue.i \ + $(WRAPPER_ROOT)/ace/Message_Queue.cpp \ + $(WRAPPER_ROOT)/ace/ReactorEx.i \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/FIFO_Recv_Msg.h \ + $(WRAPPER_ROOT)/ace/FIFO_Recv.h \ + $(WRAPPER_ROOT)/ace/FIFO.h \ + $(WRAPPER_ROOT)/ace/FIFO.i \ + $(WRAPPER_ROOT)/ace/FIFO_Recv.i \ + $(WRAPPER_ROOT)/ace/FIFO_Recv_Msg.i + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Reactor/FIFO/client.cpp b/examples/Reactor/FIFO/client.cpp new file mode 100644 index 00000000000..5bee3c8548f --- /dev/null +++ b/examples/Reactor/FIFO/client.cpp @@ -0,0 +1,17 @@ +#include "ace/FIFO_Send_Msg.h" + +int +main (void) +{ + char buf[] = "hello world"; + ACE_Str_Buf msg (buf, sizeof buf); + + ACE_FIFO_Send_Msg fifo_sender (ACE_DEFAULT_RENDEZVOUS, + O_WRONLY | O_CREAT, + ACE_DEFAULT_FILE_PERMS); + + if (fifo_sender.send (&msg) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send error for fifo"), -1); + else + return 0; +} diff --git a/examples/Reactor/FIFO/server.cpp b/examples/Reactor/FIFO/server.cpp new file mode 100644 index 00000000000..59b585d5f7c --- /dev/null +++ b/examples/Reactor/FIFO/server.cpp @@ -0,0 +1,80 @@ +#include "ace/Service_Config.h" +#include "ace/FIFO_Recv_Msg.h" + +class FIFO_Recv_Handler : public ACE_Event_Handler +{ +public: + FIFO_Recv_Handler (void); + ~FIFO_Recv_Handler (void); + + virtual ACE_HANDLE get_handle (void) const; + virtual int handle_input (ACE_HANDLE fd); + +private: + ACE_FIFO_Recv_Msg fifo_reader_; +}; + +FIFO_Recv_Handler::FIFO_Recv_Handler (void) +{ + ACE_OS::unlink (ACE_DEFAULT_RENDEZVOUS); + + // Make sure to open the FIFO with the "persistent" flag enabled + // (which is the default). + if (this->fifo_reader_.open (ACE_DEFAULT_RENDEZVOUS) == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "open")); + + // Register with the Reactor. + if (ACE_Service_Config::reactor ()->register_handler + (this, ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "register_handler")); +} + +ACE_HANDLE +FIFO_Recv_Handler::get_handle (void) const +{ + return this->fifo_reader_.get_handle (); +} + +FIFO_Recv_Handler::~FIFO_Recv_Handler (void) +{ + this->fifo_reader_.close (); + this->fifo_reader_.remove (); +} + +int +FIFO_Recv_Handler::handle_input (ACE_HANDLE) +{ + char buf[BUFSIZ]; + + ACE_DEBUG ((LM_DEBUG, "handle_input\n")); + + ACE_Str_Buf msg (buf, 0, sizeof buf); + + ssize_t n = this->fifo_reader_.recv (msg); + + if (n < 0) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "recv"), -1); + else + { + ACE_DEBUG ((LM_DEBUG, "msg.len = %d, n = %d\n", msg.len, n)); + + if (msg.len > 0) + { + // Do some work in here... + ACE_DEBUG ((LM_DEBUG, "msg.buf = %s\n", msg.buf)); + } + return 0; + } +} + +int +main (int, char *argv[]) +{ + ACE_Service_Config daemon (argv[0]); + + FIFO_Recv_Handler fr_handler; + + ACE_Service_Config::run_reactor_event_loop (); + + return 0; +} diff --git a/examples/Reactor/Makefile b/examples/Reactor/Makefile index 4613709a2a2..b5cd2f404a0 100644 --- a/examples/Reactor/Makefile +++ b/examples/Reactor/Makefile @@ -9,6 +9,7 @@ #---------------------------------------------------------------------------- DIRS = Dgram \ + FIFO \ Misc \ Multicast \ Ntalker diff --git a/examples/Reactor/Misc/notification.cpp b/examples/Reactor/Misc/notification.cpp index 89a75d7b33b..9a5853d1c17 100644 --- a/examples/Reactor/Misc/notification.cpp +++ b/examples/Reactor/Misc/notification.cpp @@ -2,8 +2,15 @@ #include "ace/Service_Config.h" #include "ace/Thread.h" +#include "ace/Synch_T.h" #if defined (ACE_HAS_THREADS) +#if defined (CHORUS) +// Chorus does not have signal, so we'll stop after a number of rounds. +#define MAX_ITERATIONS 3 +#else +#define MAX_ITERATIONS 10000 +#endif class Thread_Handler : public ACE_Event_Handler // = TITLE @@ -49,6 +56,8 @@ private: size_t id_; // ID passed in by Thread_Handler constructor. + int iterations_; + static sig_atomic_t shutdown_; // Shutting down. @@ -69,17 +78,21 @@ ACE_Time_Value Thread_Handler::delay_; // Interval factor for Event_Handler timer. ACE_Time_Value Thread_Handler::interval_; + Thread_Handler::Thread_Handler (int delay, int interval, size_t n_threads) + : iterations_(MAX_ITERATIONS) { delay_.set (delay); interval_.set (interval); +#if !defined(CHORUS) ACE_Sig_Set sig_set; sig_set.sig_add (SIGQUIT); sig_set.sig_add (SIGINT); +#endif this->id_ = 0; @@ -88,8 +101,10 @@ Thread_Handler::Thread_Handler (int delay, ACE_Service_Config::thr_mgr ()) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "register_stdin_handler")); +#if !defined(CHORUS) else if (ACE_Service_Config::reactor ()->register_handler (sig_set, this) == -1) ACE_ERROR ((LM_ERROR, "(%t) %p\n", "register_handler")); +#endif else if (ACE_Service_Config::reactor ()->schedule_timer (this, 0, Thread_Handler::delay_, Thread_Handler::interval_) == -1) @@ -98,7 +113,9 @@ Thread_Handler::Thread_Handler (int delay, // Set up this thread's signal mask, which is inherited by the // threads it spawns. +#if !defined(CHORUS) ACE_Thread::sigsetmask (SIG_BLOCK, sig_set); +#endif // Create N new threads of control Thread_Handlers. @@ -109,7 +126,9 @@ Thread_Handler::Thread_Handler (int delay, ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Thread::spawn")); // Unblock signal set so that only this thread receives them! +#if !defined(CHORUS) ACE_Thread::sigsetmask (SIG_UNBLOCK, sig_set); +#endif } int @@ -120,17 +139,18 @@ Thread_Handler::notify (ACE_Time_Value *timeout) if (ACE_Service_Config::reactor ()->notify (this, ACE_Event_Handler::EXCEPT_MASK, timeout) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "notify"), -1); - + ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", + "notification::notify:exception"), -1); else if (ACE_Service_Config::reactor ()->notify (this, ACE_Event_Handler::WRITE_MASK, timeout) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "notify"), -1); + ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", + "notification::notify:write"), -1); return 0; } // Test stdin handling (can use select to demultiplex HANDLEs) - +// Input is only handled by the main thread int Thread_Handler::handle_input (ACE_HANDLE handle) { @@ -138,18 +158,31 @@ Thread_Handler::handle_input (ACE_HANDLE handle) ssize_t n = ACE_OS::read (handle, buf, sizeof buf); if (n > 0) - { - ACE_DEBUG ((LM_DEBUG, "(%t) %*s", n, buf)); - - // Only wait up to 10 milliseconds to notify the Reactor. - ACE_Time_Value timeout (0, 10 * 1000); - - if (this->notify (&timeout) == -1) - ACE_ERROR ((LM_DEBUG, "(%t), %p\n", "notify")); + { + ACE_DEBUG ((LM_DEBUG, "input to (%t) %*s", + n, buf)); + + if (--iterations_ <= 0) + { + // would like to put this in handle_timeout(), but chorus + // clock_gettime() does not seem to work in my version! + ACE_Service_Config::end_reactor_event_loop(); + } + else + { + ACE_DEBUG ((LM_DEBUG, "%d more input to kill\n", + iterations_)); + // Only wait up to 10 milliseconds to notify the Reactor. + ACE_Time_Value timeout (0, 10 * 1000); + + if (this->notify (&timeout) == -1) + ACE_ERROR ((LM_DEBUG, "(%t), %p\n", + "notification::handle_input:notify")); + } return 0; - } + } else - return -1; + return -1; } // Perform a task that will test the ACE_Reactor's multi-threading @@ -158,7 +191,9 @@ Thread_Handler::handle_input (ACE_HANDLE handle) int Thread_Handler::svc (void) { - while (this->shutdown_ == 0) + iterations_ = MAX_ITERATIONS; + + while (this->shutdown_ == 0 && --iterations_ > 0 ) { if (Thread_Handler::delay_.sec () > 0) // Block for delay_.secs () / 2, then notify the Reactor. @@ -171,6 +206,7 @@ Thread_Handler::svc (void) ACE_ERROR ((LM_ERROR, "(%t) %p\n", "notify")); } + ACE_Service_Config::reactor()->remove_handler(this, ALL_EVENTS_MASK); ACE_DEBUG ((LM_DEBUG, "(%t) exiting svc\n")); return 0; } @@ -210,7 +246,7 @@ int Thread_Handler::handle_exception (ACE_HANDLE) { ACE_DEBUG ((LM_DEBUG, - "(%t) handle_exception received notification from id %d\n", + "(%t) exception to id %d\n", this->id_)); return 0; } @@ -221,7 +257,7 @@ int Thread_Handler::handle_output (ACE_HANDLE) { ACE_DEBUG ((LM_DEBUG, - "(%t) handle_output received notification from id %d\n", + "(%t) output to id %d\n", this->id_)); return 0; } diff --git a/examples/Reactor/Misc/pingpong.cpp b/examples/Reactor/Misc/pingpong.cpp index e3b1ead8c81..e77ff89ab6d 100644 --- a/examples/Reactor/Misc/pingpong.cpp +++ b/examples/Reactor/Misc/pingpong.cpp @@ -1,6 +1,6 @@ -/* Simple program that illustrates all the features of the ACE_Reactor: // $Id$ +/* Simple program that illustrates many features of the ACE_Reactor: 1. I/O event demultiplexing 2. Signal-based demultiplexing @@ -99,7 +99,7 @@ Ping_Pong::handle_input (ACE_HANDLE) *(int *) (this->buf_ + sizeof (int)), this->buf_ + (2 * sizeof (int)))); #else - ssize_t n = ACE::recv (this->handle_, this->buf_, sizeof this->buf_); + ssize_t n = ACE::recv (this->handle_, this->buf_, this->buflen_); if (n == -1) ACE_ERROR_RETURN ((LM_ERROR, "[%d] %p\n", handle_, "read"), -1); @@ -156,21 +156,6 @@ static char *string_name; // Wait for 10 seconds and then shut down. static const int SHUTDOWN_TIME = 10; -#if defined (ACE_WIN32) -static ACE_Barrier barrier (3); - -static void * -worker (void *arg) -{ - ACE_HANDLE handle = (ACE_HANDLE) arg; - - run_svc (handle); - barrier.wait (); - ACE_DEBUG ((LM_DEBUG, "(%P|%t) %n: shutting down tester\n")); - return 0; -} -#endif /* ACE_WIN32 */ - static void run_svc (ACE_HANDLE handle) { @@ -184,7 +169,9 @@ run_svc (ACE_HANDLE handle) if (reactor.register_handler (&callback, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK) == -1 +#if !defined (CHORUS) || reactor.register_handler (SIGINT, &callback) == -1 +#endif /* CHORUS */ || reactor.schedule_timer (&callback, 0, SHUTDOWN_TIME) == -1) ACE_ERROR ((LM_ERROR, "%p\n%a", "reactor", 1)); @@ -195,6 +182,21 @@ run_svc (ACE_HANDLE handle) ACE_ERROR ((LM_ERROR, "%p\n", "handle_events")); } +#if defined (ACE_WIN32) || defined (CHORUS) +static ACE_Barrier barrier (3); + +static void * +worker (void *arg) +{ + ACE_HANDLE handle = (ACE_HANDLE) arg; + + run_svc (handle); + barrier.wait (); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) %n: shutting down tester\n")); + return 0; +} +#endif /* ACE_WIN32 */ + int main (int argc, char *argv[]) { @@ -210,7 +212,7 @@ main (int argc, char *argv[]) // Create a pipe and initialize the handles. ACE_Pipe pipe (handles); -#if defined (ACE_WIN32) +#if defined (ACE_WIN32) || defined (CHORUS) if (ACE_Thread::spawn (ACE_THR_FUNC (worker), (void *) handles[0], THR_DETACHED) == -1 @@ -220,7 +222,6 @@ main (int argc, char *argv[]) ACE_ERROR ((LM_ERROR, "%p\n%a", "spawn", 1)); barrier.wait (); - #else pid_t pid = ACE_OS::fork (argv[0]); diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.cpp b/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.cpp index 06d8c724040..79fd3c65331 100644 --- a/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.cpp +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.cpp @@ -1,7 +1,6 @@ #include "Handle_L_FIFO.h" // $Id$ - #if defined (SunOS4) extern "C" { diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.i b/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.i index 8b667cb6681..860cc2009ed 100644 --- a/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.i +++ b/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.i @@ -54,8 +54,8 @@ Handle_L_FIFO::init (int argc, char *argv[]) ACE_OS::unlink (rendezvous_fifo); if (this->open (rendezvous_fifo) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); - else if (ACE_Service_Config::reactor ()->register_handler (this, - ACE_Event_Handler::ACCEPT_MASK) == -1) + else if (ACE_Service_Config::reactor ()->register_handler + (this, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "registering service with ACE_Reactor\n"), -1); return 0; } @@ -63,7 +63,8 @@ Handle_L_FIFO::init (int argc, char *argv[]) ACE_INLINE int Handle_L_FIFO::fini (void) { - return ACE_Service_Config::reactor ()->remove_handler (this, ACE_Event_Handler::ACCEPT_MASK); + return ACE_Service_Config::reactor ()->remove_handler + (this, ACE_Event_Handler::ACCEPT_MASK); } ACE_INLINE int |