diff options
31 files changed, 534 insertions, 329 deletions
diff --git a/ChangeLog-96b b/ChangeLog-96b index cff3dde8bb7..ecbe7b137ae 100644 --- a/ChangeLog-96b +++ b/ChangeLog-96b @@ -1,15 +1,71 @@ +Sun Nov 24 12:30:45 1996 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * ace: Began adding support for WinSock 2.0. Thanks to Luca for + this. + + * ace/UPIPE_{Acceptor,Connector,Stream}: Updated the UPIPE + components so that they keep a reference count that keeps track + of the number of "owners" (which should always be 2 -- one for + the connector-side and one for the acceptor-side). By keeping + this count, we can ensure that we don't close down the + underlying ACE_Stream until both sides have called close(). + This will remove a nasty bug that was lurking in some of the + tests. + + * ace/Message_Block.h: Added a new copy() method that assumes the + buf passed in is a NUL-terminated string. + + * tests/UPIPE_SAP_Test.cpp: Modified this test so that threads + exit in a well-defined order. This should prevent problems on + Win32. + + * ace/OS.i: Changed SIGNAL_SAFE_OS_CALLS to + ACE_HAS_SIGNAL_SAFE_OS_CALLS to be consistent... + + * ace/config-vxworks*.h: Removed the SIGNAL_SAFE_OS_CALLS #define + from the VxWorks config files. There's no need to use this by + default. + + * ace/Event_Handler: Moved all the default implementations of the + virtual methods in ACE_Event_Handler from the *.i file to the + *.cpp and made them no longer be inlines. This will fix some + problems with some compilers (e.g., MSVC++ 4.1) and is also more + reasonable since there's really no purpose for inlining these + virtual functions since they are rarely called. Thanks to James + Michael Dwyer <jdwyer@knox.edu> for reporting this problem. + +Sat Nov 23 12:39:03 1996 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * ace/Svc_Conf.y: Changed the parser so that it accepts DLL + pathnames that lack *.dll or *.so suffixes. This is necessary + so that we can automatically append the correct suffix depending + on the platform. Thanks to Tilo Christ + <christ@swl.fh-heilbronn.de> for suggesting this. + + * ace/Makefile: Updated the Makefile so that it will automatically + insert the appropriate so that conditions for include of + ace/OS.h can be checked correctly. + +Fri Nov 22 18:12:49 1996 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * ace/OS.i (thr_sigsetmask): DCE threads (at least as implemented + by Digital) have no means for setting the signal mask on a + per-thread basis. Therefore, modified the code so that it + correctly returns ACE_NOTSUP_RETURN(-1) for DCEthreads. Thanks + to Thilo Kielmann <kielmann@informatik.uni-siegen.de> for + chasing this down. + + * performance-tests/Synch-Benchmarks/synch_driver.cpp (run_test): + Fixed this implementation so that it will shut down correctly + when a signal occurs or a timeout occurs (whichever comes + first). + Fri Nov 22 08:02:39 1996 Irfan Pyarali <irfan@flamenco.cs.wustl.edu> * ace.{mdp,mak}: Changed ace.mak so that it links with the non-debug version of Microsoft's multithreaded dll when compiled with the release option -Wed Nov 20 10:32:52 1996 Irfan Pyarali <irfan@flamenco.cs.wustl.edu> - - * tests: Mutex_Test.cpp Priority_Buffer_Test.cpp - Reader_Writer_Test.cpp Thread_Pool_Test.cpp were changed - slightly to remove some compile time warnings. - Thu Nov 21 10:37:40 1996 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> * ace/Service_Config: Changed the implementation of the @@ -48,7 +104,9 @@ Thu Nov 21 10:37:40 1996 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> <make@cs.tu-berlin.de> for this suggestion! * ace/OS.cpp: Added support for AfxBeginThread in - ACE_OS::thr_create(). Thanks to Matthias Kerkhoff + ACE_OS::thr_create() and ACE_OS::exit(). Now ACE should work + with MFC when you give the THR_USE_AFX flag to + ACE_OS::thr_create()! Thanks to Matthias Kerkhoff <make@cs.tu-berlin.de> for this! * ace/Malloc_T.cpp (avail_chunks): Changed the return value to @@ -101,15 +159,23 @@ Thu Nov 21 10:37:40 1996 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> proves that he's a macho man, not a boy ;-) Thu Nov 21 08:12:51 1996 David L. Levine <levine@cs.wustl.edu> + * include/makeinclude/platform_sunos5_sunc++_4.1.GNU: put back the LD definition * include/makeinclude/platform_osf1_4.0_g++.GNU: added LD definition to work with latest wrapper_macros.GNU +Wed Nov 20 10:32:52 1996 Irfan Pyarali <irfan@flamenco.cs.wustl.edu> + + * tests: Mutex_Test.cpp Priority_Buffer_Test.cpp + Reader_Writer_Test.cpp Thread_Pool_Test.cpp were changed + slightly to remove some compile time warnings. + Wed Nov 20 21:35:28 1996 David L. Levine <levine@cs.wustl.edu> + * ace/Svc_Conf_l.cpp: added #include of ace/config.h so that - conditions for include of ace/OS.h can be checked + conditions for include of ace/OS.h can be checked. Wed Nov 20 02:38:40 1996 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> @@ -661,6 +661,7 @@ Matthias Kerkhoff <make@cs.tu-berlin.de> Fred LaBar <flabar@fallschurch.esys.com> Hanan Herzog <hanan@wallenda.stanford.edu> Eric Parker <eparker@credence.com> +James Michael Dwyer <jdwyer@knox.edu> I would particularly like to thank Paul Stephenson, who worked with me at Ericsson and is now at ObjectSpace. Paul devised the recursive diff --git a/ace/Event_Handler.cpp b/ace/Event_Handler.cpp index c0cc76fbd09..e23bfb231f4 100644 --- a/ace/Event_Handler.cpp +++ b/ace/Event_Handler.cpp @@ -9,3 +9,175 @@ #include "ace/Event_Handler.i" #endif /* __ACE_INLINE__ */ +// Implement conceptually abstract virtual functions in the base class +// so derived classes don't have to implement unused ones. + +ACE_Event_Handler::ACE_Event_Handler (void) + : priority_ (ACE_Event_Handler::LO_PRIORITY), + reactor_ (0), + reactorex_ (0), + proactor_ (0) +{ + ACE_TRACE ("ACE_Event_Handler::ACE_Event_Handler"); +} + +ACE_Event_Handler::~ACE_Event_Handler (void) +{ + ACE_TRACE ("ACE_Event_Handler::~ACE_Event_Handler"); +} + +// Gets the file descriptor associated with this I/O device. + +ACE_HANDLE +ACE_Event_Handler::get_handle (void) const +{ + ACE_TRACE ("ACE_Event_Handler::get_handle"); + return ACE_INVALID_HANDLE; +} + +// Sets the file descriptor associated with this I/O device. + +void +ACE_Event_Handler::set_handle (ACE_HANDLE) +{ + ACE_TRACE ("ACE_Event_Handler::set_handle"); +} + +// Gets the priority of this handler. + +int +ACE_Event_Handler::get_priority (void) const +{ + ACE_TRACE ("ACE_Event_Handler::get_priority"); + return this->priority_; +} + +// Sets the priority + +void +ACE_Event_Handler::set_priority (int priority) +{ + ACE_TRACE ("ACE_Event_Handler::set_priority"); + this->priority_ = priority; +} + +// Called when the object is about to be removed from the Dispatcher +// tables. + +int +ACE_Event_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + ACE_TRACE ("ACE_Event_Handler::handle_close"); + return -1; +} + +// Called when input becomes available on fd. + +int +ACE_Event_Handler::handle_input (ACE_HANDLE) +{ + ACE_TRACE ("ACE_Event_Handler::handle_input"); + return -1; +} + +// Called when output is possible on fd. + +int +ACE_Event_Handler::handle_output (ACE_HANDLE) +{ + ACE_TRACE ("ACE_Event_Handler::handle_output"); + return -1; +} + +// Called when urgent data is available on fd. + +int +ACE_Event_Handler::handle_exception (ACE_HANDLE) +{ + ACE_TRACE ("ACE_Event_Handler::handle_exception"); + return -1; +} + +// Called when timer expires, TV stores the current time. + +int +ACE_Event_Handler::handle_timeout (const ACE_Time_Value &, const void *) +{ + ACE_TRACE ("ACE_Event_Handler::handle_timeout"); + return -1; +} + +// Called when a registered signal occurs. + +int +ACE_Event_Handler::handle_signal (int, siginfo_t *, ucontext_t *) +{ + ACE_TRACE ("ACE_Event_Handler::handle_signal"); + return -1; +} + +int +ACE_Event_Handler::handle_input_complete (ACE_Message_Block *, long) +{ + ACE_TRACE ("ACE_Event_Handler::handle_input_complete"); + return -1; +} + +int +ACE_Event_Handler::handle_output_complete (ACE_Message_Block *, long) +{ + ACE_TRACE ("ACE_Event_Handler::handle_input_complete"); + return -1; +} + +ACE_Message_Block * +ACE_Event_Handler::get_message (void) +{ + ACE_TRACE ("ACE_Event_Handler::get_message"); + return 0; +} + +void +ACE_Event_Handler::reactor (ACE_Reactor *reactor) +{ + ACE_TRACE ("ACE_Event_Handler::reactor"); + this->reactor_ = reactor; +} + +ACE_Reactor * +ACE_Event_Handler::reactor (void) const +{ + ACE_TRACE ("ACE_Event_Handler::Reactor"); + return this->reactor_; +} + +void +ACE_Event_Handler::reactorex (ACE_ReactorEx *reactorex) +{ + ACE_TRACE ("ACE_Event_Handler::reactorex"); + this->reactorex_ = reactorex; +} + +ACE_ReactorEx * +ACE_Event_Handler::reactorex (void) const +{ + ACE_TRACE ("ACE_Event_Handler::ReactorEx"); + + return this->reactorex_; +} + +void +ACE_Event_Handler::proactor (ACE_Proactor *proactor) +{ + ACE_TRACE ("ACE_Event_Handler::proactor"); + + this->proactor_ = proactor; +} + +ACE_Proactor * +ACE_Event_Handler::proactor (void) const +{ + ACE_TRACE ("ACE_Event_Handler::Proactor"); + + return this->proactor_; +} diff --git a/ace/Event_Handler.i b/ace/Event_Handler.i index d9e30724ce5..18110dfeffe 100644 --- a/ace/Event_Handler.i +++ b/ace/Event_Handler.i @@ -4,178 +4,4 @@ #include "ace/Event_Handler.h" // Event_Handler.i -// Implement conceptually abstract virtual functions in the base class -// so derived classes don't have to implement unused ones. - -ACE_INLINE -ACE_Event_Handler::ACE_Event_Handler (void) - : priority_ (ACE_Event_Handler::LO_PRIORITY), - reactor_ (0), - reactorex_ (0), - proactor_ (0) -{ - ACE_TRACE ("ACE_Event_Handler::ACE_Event_Handler"); -} - -ACE_INLINE -ACE_Event_Handler::~ACE_Event_Handler (void) -{ - ACE_TRACE ("ACE_Event_Handler::~ACE_Event_Handler"); -} - -// Gets the file descriptor associated with this I/O device. - -ACE_INLINE ACE_HANDLE -ACE_Event_Handler::get_handle (void) const -{ - ACE_TRACE ("ACE_Event_Handler::get_handle"); - return ACE_INVALID_HANDLE; -} - -// Sets the file descriptor associated with this I/O device. - -ACE_INLINE void -ACE_Event_Handler::set_handle (ACE_HANDLE) -{ - ACE_TRACE ("ACE_Event_Handler::set_handle"); -} - -// Gets the priority of this handler. - -ACE_INLINE int -ACE_Event_Handler::get_priority (void) const -{ - ACE_TRACE ("ACE_Event_Handler::get_priority"); - return this->priority_; -} - -// Sets the priority - -ACE_INLINE void -ACE_Event_Handler::set_priority (int priority) -{ - ACE_TRACE ("ACE_Event_Handler::set_priority"); - this->priority_ = priority; -} - -// Called when the object is about to be removed from the Dispatcher -// tables. - -ACE_INLINE int -ACE_Event_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) -{ - ACE_TRACE ("ACE_Event_Handler::handle_close"); - return -1; -} - -// Called when input becomes available on fd. - -ACE_INLINE int -ACE_Event_Handler::handle_input (ACE_HANDLE) -{ - ACE_TRACE ("ACE_Event_Handler::handle_input"); - return -1; -} - -// Called when output is possible on fd. - -ACE_INLINE int -ACE_Event_Handler::handle_output (ACE_HANDLE) -{ - ACE_TRACE ("ACE_Event_Handler::handle_output"); - return -1; -} - -// Called when urgent data is available on fd. - -ACE_INLINE int -ACE_Event_Handler::handle_exception (ACE_HANDLE) -{ - ACE_TRACE ("ACE_Event_Handler::handle_exception"); - return -1; -} - -// Called when timer expires, TV stores the current time. - -ACE_INLINE int -ACE_Event_Handler::handle_timeout (const ACE_Time_Value &, const void *) -{ - ACE_TRACE ("ACE_Event_Handler::handle_timeout"); - return -1; -} - -// Called when a registered signal occurs. - -ACE_INLINE int -ACE_Event_Handler::handle_signal (int, siginfo_t *, ucontext_t *) -{ - ACE_TRACE ("ACE_Event_Handler::handle_signal"); - return -1; -} - -ACE_INLINE int -ACE_Event_Handler::handle_input_complete (ACE_Message_Block *, long) -{ - ACE_TRACE ("ACE_Event_Handler::handle_input_complete"); - return -1; -} - -ACE_INLINE int -ACE_Event_Handler::handle_output_complete (ACE_Message_Block *, long) -{ - ACE_TRACE ("ACE_Event_Handler::handle_input_complete"); - return -1; -} - -ACE_INLINE ACE_Message_Block * -ACE_Event_Handler::get_message (void) -{ - ACE_TRACE ("ACE_Event_Handler::get_message"); - return 0; -} - -ACE_INLINE void -ACE_Event_Handler::reactor (ACE_Reactor *reactor) -{ - ACE_TRACE ("ACE_Event_Handler::reactor"); - this->reactor_ = reactor; -} - -ACE_INLINE ACE_Reactor * -ACE_Event_Handler::reactor (void) const -{ - ACE_TRACE ("ACE_Event_Handler::Reactor"); - return this->reactor_; -} - -ACE_INLINE void -ACE_Event_Handler::reactorex (ACE_ReactorEx *reactorex) -{ - ACE_TRACE ("ACE_Event_Handler::reactorex"); - this->reactorex_ = reactorex; -} - -ACE_INLINE ACE_ReactorEx * -ACE_Event_Handler::reactorex (void) const -{ - ACE_TRACE ("ACE_Event_Handler::ReactorEx"); - - return this->reactorex_; -} - -ACE_INLINE void -ACE_Event_Handler::proactor (ACE_Proactor *proactor) -{ - ACE_TRACE ("ACE_Event_Handler::proactor"); - - this->proactor_ = proactor; -} - -ACE_INLINE ACE_Proactor * -ACE_Event_Handler::proactor (void) const -{ - ACE_TRACE ("ACE_Event_Handler::Proactor"); - - return this->proactor_; -} diff --git a/ace/Message_Block.cpp b/ace/Message_Block.cpp index 96e94d460ae..5c0947f806a 100644 --- a/ace/Message_Block.cpp +++ b/ace/Message_Block.cpp @@ -28,6 +28,24 @@ ACE_Message_Block::copy (const char *buf, size_t n) } } +int +ACE_Message_Block::copy (const char *buf) +{ + ACE_TRACE ("ACE_Message_Block::copy"); + // Note that for this to work correct, end() *must* be >= wr_ptr(). + size_t len = size_t (this->end () - this->wr_ptr ()); + size_t buflen = ACE_OS::strlen (buf) + 1; + + if (len < buflen) + return -1; + else + { + (void) ACE_OS::memcpy (this->wr_ptr (), buf, buflen); + this->wr_ptr (buflen); + return 0; + } +} + void ACE_Message_Block::dump (void) const { diff --git a/ace/Message_Block.h b/ace/Message_Block.h index c94fbfffc81..599e1039813 100644 --- a/ace/Message_Block.h +++ b/ace/Message_Block.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY @@ -153,6 +152,11 @@ public: // the wr_ptr() offset. Return 0 if succeeds and -1 if the size of // the message is too small... + int copy (const char *buf); + // Copies <buf> into the Message_Block starting at the wr_ptr() + // offset. This call assumees that <buf> is NUL-terminated. Return + // 0 if succeeds and -1 if the size of the message is too small... + char *base (void) const; // Get message data. diff --git a/ace/OS.cpp b/ace/OS.cpp index 916f6a2adc6..b0aaac73e43 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -407,12 +407,12 @@ ACE_TSS_Cleanup::exit (void *status) #if defined (ACE_HAS_MFC) // allow CWinThread-destructor to be invoked from AfxEndThread - // _endthreadex() will be called from AfxEndThread so don't exit the + // _endthreadex will be called from AfxEndThread so don't exit the // thread now if we are running an MFC thread. - // if (ACE_BIT_DISABLED (flags, THR_USE_AFX)) + CWinThread *pThread = ::AfxGetThread (); + if (!pThread || pThread->m_nThreadID != ACE_OS::thr_self ()) #endif /* ACE_HAS_MFC */ - ::_endthreadex ((DWORD) status); - + ::_endthreadex ((DWORD) status); #if 0 ::ExitThread ((DWORD) status); #endif @@ -1035,7 +1035,12 @@ PAGE_NOCACHE */ #include /**/ <windows.h> #endif /* __AFX_H__ */ +#if defined (ACE_HAS_WINSOCK2) +#include /**/ <winsock2.h> +#include "ace/ws2tcpip.h" +#else #include /**/ <winsock.h> +#endif /* ACE_HAS_WINSOCK2 */ #define MAXHOSTNAMELEN 256 @@ -159,7 +159,7 @@ extern "C" char *mktemp (char *); #define ACE_ADAPT_RETVAL(OP,RESULT) ((RESULT = (OP)) != 0 ? (errno = RESULT, -1) : 0) #endif /* VXWORKS */ -#if defined (SIGNAL_SAFE_OS_CALLS) +#if defined (ACE_HAS_SIGNAL_SAFE_OS_CALLS) #include "ace/Log_Msg.h" // The following two macros ensure that system calls are properly // restarted (if necessary) when interrupts occur. @@ -178,7 +178,7 @@ extern "C" char *mktemp (char *); #else #define ACE_OSCALL_RETURN(OP,TYPE,FAILVALUE) do { TYPE ace_result_ = FAILVALUE; ace_result_ = ace_result_; return OP; } while (0) #define ACE_OSCALL(OP,TYPE,FAILVALUE,RESULT) do { RESULT = (TYPE) OP; } while (0) -#endif /* SIGNAL_SAFE_OS_CALLS */ +#endif /* ACE_HAS_SIGNAL_SAFE_OS_CALLS */ ACE_INLINE int ACE_OS::chdir (const char *path) @@ -3212,23 +3212,13 @@ ACE_OS::thr_sigsetmask (int how, ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_sigsetmask (how, nsm, osm), ace_result_), int, -1); -#elif defined (ACE_HAS_SETKIND_NP) - // ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sigaction (how, nsm, osm), - // ace_result_), - // int, -1); - // commented this out since nothing appropriate - // found in the man pages... - ACE_NOTSUP_RETURN (-1); - -#elif defined (ACE_HAS_DCETHREADS) -#if defined (ACE_HAS_PTHREADS_1003_DOT_1C) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigaction (how, nsm, osm), - ace_result_), int, -1); -#else +#elif defined (ACE_HAS_SETKIND_NP) || defined (ACE_HAS_DCETHREADS) + // DCE threads have no such function. + ACE_NOTSUP_RETURN (-1); +#elif defined (ACE_HAS_PTHREADS_1003_DOT_1C) + // PTHREADS_1003_DOT_1C is NOT a subcase of DCETHREADS! ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sigthreadmask (how, nsm, osm), ace_result_), int, -1); -#endif /* ACE_HAS_PTHREADS_1003_DOT_1C */ - #elif defined (ACE_HAS_PTHREADS) && !defined (ACE_HAS_FSU_PTHREADS) #if defined (ACE_HAS_IRIX62_THREADS) || defined (DIGITAL_UNIX) ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsm, osm), diff --git a/ace/README b/ace/README index 2faf0ba6c2f..a4d5eb6ebbe 100644 --- a/ace/README +++ b/ace/README @@ -72,6 +72,7 @@ ACE_HAS_RTLD_LAZY_V Explicit dynamic linking permits "lazy" symbol resolution ACE_HAS_SELECT_H Platform has special header for select(). ACE_HAS_SEMUN Compiler/platform defines a union semun for SysV shared memory ACE_HAS_SIGINFO_T Platform supports SVR4 extended signals +ACE_HAS_SIGNAL_SAFE_OS_CALLS Automatically restart OS system calls when EINTR occurs ACE_HAS_SIGWAIT Platform/compiler has the sigwait(2) prototype ACE_HAS_SIG_ATOMIC_T Compiler/platform defines the sig_atomic_t typedef ACE_HAS_SIN_LEN Platform supports new BSD inet_addr len field. @@ -121,6 +122,7 @@ ACE_HAS_UNICODE Platform/compiler supports UNICODE ACE_HAS_VOIDPTR_MMAP Platform requires void * for mmap(). ACE_HAS_VOIDPTR_SOCKOPT OS/compiler uses void * arg 4 setsockopt() rather than const char * ACE_HAS_WIN32_TRYLOCK The Win32 platform support TryEnterCriticalSection() +ACE_HAS_WINSOCK2 The Win32 platform supports WinSock 2.0 ACE_HAS_XLI Platform has the XLI version of TLI ACE_HAS_XT Platform has Xt and Motif ACE_HAS_YIELD_VOID_PTR Platform requires pthread_yield() to take a NULL. diff --git a/ace/ReactorEx.h b/ace/ReactorEx.h index 3b1bcc84a4b..18c2e0a0be0 100644 --- a/ace/ReactorEx.h +++ b/ace/ReactorEx.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY diff --git a/ace/Service_Config.h b/ace/Service_Config.h index a0389f40c57..d462f3b4752 100644 --- a/ace/Service_Config.h +++ b/ace/Service_Config.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY diff --git a/ace/Svc_Conf.y b/ace/Svc_Conf.y index 842fbf1ce7b..b75324a7c52 100644 --- a/ace/Svc_Conf.y +++ b/ace/Svc_Conf.y @@ -23,7 +23,7 @@ ACE_Obstack *ace_obstack; %start svc_config_entries -%type <ident_> ACE_IDENT ACE_STRING ACE_PATHNAME parameters_opt +%type <ident_> ACE_IDENT ACE_STRING ACE_PATHNAME pathname parameters_opt %type <type_> type status %type <parse_node_> dynamic static suspend resume remove module_list stream %type <parse_node_> stream_modules module svc_config_entry @@ -207,11 +207,11 @@ status ; svc_initializer - : ACE_PATHNAME ACE_COLON ACE_IDENT + : pathname ACE_COLON ACE_IDENT { $$ = new ACE_Object_Node ($1, $3); } - | ACE_PATHNAME ACE_COLON ACE_IDENT ACE_LPAREN ACE_RPAREN + | pathname ACE_COLON ACE_IDENT ACE_LPAREN ACE_RPAREN { $$ = new ACE_Function_Node ($1, $3); } @@ -237,6 +237,11 @@ parameters_opt | /* EMPTY */ { $$ = 0; } ; +pathname + : ACE_PATHNAME + | ACE_IDENT + ; + %% // Prints the error string to standard output. Cleans up the error // messages. diff --git a/ace/Svc_Conf_Tokens.h b/ace/Svc_Conf_Tokens.h index 39e0e0ac4f0..4b5d3b3e8f1 100644 --- a/ace/Svc_Conf_Tokens.h +++ b/ace/Svc_Conf_Tokens.h @@ -1,6 +1,3 @@ -/* -*- C++ -*- */ -// $Id$ - #define ACE_DYNAMIC 257 #define ACE_STATIC 258 #define ACE_SUSPEND 259 diff --git a/ace/Svc_Conf_l.cpp b/ace/Svc_Conf_l.cpp index 9495714f23a..acce4462d2c 100644 --- a/ace/Svc_Conf_l.cpp +++ b/ace/Svc_Conf_l.cpp @@ -1,6 +1,8 @@ +#include "ace/config.h" +#if defined (HPUX) || defined (VXWORKS) +#include "ace/OS.h" +#endif /* HPUX || VXWORKS */ /* A lexical scanner generated by flex */ -// $Id$ - /* Scanner skeleton version: * $Header$ @@ -8,10 +10,6 @@ #define FLEX_SCANNER -#include "ace/config.h" -#if defined (HPUX) || defined (VXWORKS) -#include "ace/OS.h" -#endif /* HPUX || VXWORKS */ #include /**/ <stdio.h> diff --git a/ace/Svc_Conf_y.cpp b/ace/Svc_Conf_y.cpp index b094b72247d..f0415eef51c 100644 --- a/ace/Svc_Conf_y.cpp +++ b/ace/Svc_Conf_y.cpp @@ -1,6 +1,4 @@ #ifndef lint -// @(#)Svc_Conf_y.cpp 1.1 10/18/96 - char ace_yysccsid[] = "@(#)yaccpar 1.4 (Berkeley) 02/25/90 \n\ Modified 5/2/90 by J. Roskind to support graphic debugging modes"; #endif @@ -44,56 +42,58 @@ ACE_Obstack *ace_obstack; #define ACE_COLON 276 #define YYERRCODE 256 short ace_yylhs[] = { -1, - 0, 0, 0, 13, 13, 13, 13, 13, 13, 4, - 5, 6, 7, 8, 10, 17, 10, 14, 14, 18, - 11, 11, 9, 9, 12, 12, 12, 12, 12, 15, - 3, 3, 3, 16, 16, 2, 2, 2, 1, 1, + 0, 0, 0, 14, 14, 14, 14, 14, 14, 5, + 6, 7, 8, 9, 11, 18, 11, 15, 15, 19, + 12, 12, 10, 10, 13, 13, 13, 13, 13, 16, + 4, 4, 4, 17, 17, 3, 3, 3, 2, 2, + 1, 1, }; short ace_yylen[] = { 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 3, 3, 2, 2, 2, 3, 0, 4, 1, 1, 0, 4, 0, 2, 0, 1, 1, 1, 1, 1, 4, 1, 1, 0, 3, 5, 2, 2, 2, 1, 0, + 1, 1, }; short ace_yydefred[] = { 3, 0, 2, 0, 0, 0, 0, 0, 0, 4, 5, 6, 7, 8, 9, 1, 0, 0, 0, 12, 13, 14, 16, 18, 19, 0, 0, 0, 0, 0, 39, - 10, 11, 0, 20, 15, 36, 38, 37, 0, 0, - 17, 24, 0, 31, 32, 30, 0, 0, 21, 25, - 26, 27, 28, 29, 23, 0, 35, + 10, 11, 0, 20, 15, 36, 38, 37, 41, 42, + 0, 0, 17, 24, 0, 31, 32, 30, 0, 0, + 21, 25, 26, 27, 28, 29, 23, 0, 35, }; short ace_yydgoto[] = { 1, - 31, 29, 46, 9, 10, 11, 12, 13, 47, 14, - 35, 55, 15, 25, 17, 40, 33, 42, + 41, 31, 29, 48, 9, 10, 11, 12, 13, 49, + 14, 35, 57, 15, 25, 17, 42, 33, 44, }; short ace_yysindex[] = { 0, - -244, 0, -266, -260, -250, -243, -239, -247, 0, 0, + -244, 0, -266, -260, -250, -243, -241, -247, 0, 0, 0, 0, 0, 0, 0, -240, -237, -237, 0, 0, - 0, 0, 0, 0, -242, -241, -235, -233, -236, 0, - 0, 0, -242, 0, 0, 0, 0, 0, -232, -238, - 0, 0, -234, 0, 0, 0, -253, -228, 0, 0, - 0, 0, 0, 0, 0, -227, 0, + 0, 0, 0, 0, -238, -236, -233, -231, -239, 0, + 0, 0, -238, 0, 0, 0, 0, 0, 0, 0, + -242, -235, 0, 0, -232, 0, 0, 0, -253, -226, + 0, 0, 0, 0, 0, 0, 0, -234, 0, }; short ace_yyrindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 27, 0, 0, 0, 0, 0, 0, 46, 0, 0, 0, 0, 0, - 0, 0, 46, 0, 0, 0, 0, 0, 0, 20, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, + 0, 0, 46, 0, 0, 0, 0, 0, 0, 0, + 0, 20, 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, }; short ace_yygindex[] = { 0, - 18, 0, 0, -8, -6, -10, -9, 2, 0, 0, - 14, 0, 0, 0, 0, 0, 0, 0, + 0, 18, 0, 0, -8, -6, -9, -2, -1, 0, + 0, 16, 0, 0, 0, 0, 0, 0, 0, }; #define YYTABLESIZE 308 short ace_yytable[] = { 23, 34, 24, 16, 3, 4, 5, 6, 7, 18, 3, 4, 2, 3, 4, 5, 6, 7, 8, 19, 33, - 49, 22, 26, 27, 28, 20, 40, 44, 45, 21, - 34, 39, 30, 36, 48, 32, 52, 53, 50, 37, - 51, 38, 56, 43, 57, 22, 41, 0, 54, 0, + 51, 22, 26, 27, 28, 20, 40, 21, 39, 40, + 46, 47, 30, 45, 34, 32, 50, 59, 36, 54, + 52, 37, 53, 38, 58, 22, 55, 56, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -124,9 +124,9 @@ short ace_yytable[] = { 23, short ace_yycheck[] = { 8, 0, 8, 269, 257, 258, 259, 260, 261, 269, 257, 258, 256, 257, 258, 259, 260, 261, 262, 269, 0, - 274, 269, 263, 264, 265, 269, 0, 266, 267, 269, - 273, 268, 270, 275, 269, 18, 47, 47, 47, 275, - 47, 275, 271, 276, 272, 0, 33, -1, 47, -1, + 274, 269, 263, 264, 265, 269, 0, 269, 268, 269, + 266, 267, 270, 276, 273, 18, 269, 272, 275, 49, + 49, 275, 49, 275, 271, 0, 49, 49, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -208,13 +208,15 @@ char *ace_yyrule[] = { "status : ACE_ACTIVE", "status : ACE_INACTIVE", "status :", -"svc_initializer : ACE_PATHNAME ACE_COLON ACE_IDENT", -"svc_initializer : ACE_PATHNAME ACE_COLON ACE_IDENT ACE_LPAREN ACE_RPAREN", +"svc_initializer : pathname ACE_COLON ACE_IDENT", +"svc_initializer : pathname ACE_COLON ACE_IDENT ACE_LPAREN ACE_RPAREN", "type : ACE_MODULE_T ACE_STAR", "type : ACE_SVC_OBJ_T ACE_STAR", "type : ACE_STREAM_T ACE_STAR", "parameters_opt : ACE_STRING", "parameters_opt :", +"pathname : ACE_PATHNAME", +"pathname : ACE_IDENT", }; #endif #define ace_yyclearin (ace_yychar=(-1)) @@ -237,7 +239,7 @@ YYSTYPE ace_yylval; #define ace_yystacksize YYSTACKSIZE short ace_yyss[YYSTACKSIZE]; YYSTYPE ace_yyvs[YYSTACKSIZE]; -#line 241 "Svc_Conf.y" +#line 246 "Svc_Conf.y" // Prints the error string to standard output. Cleans up the error // messages. @@ -340,7 +342,7 @@ main (int argc, char *argv[]) return ace_yyparse (); } #endif /* DEBUGGING */ -#line 342 "y.tab.c" +#line 346 "y.tab.c" #define YYABORT goto ace_yyabort #define YYACCEPT goto ace_yyaccept #define YYERROR goto ace_yyerrlab @@ -861,7 +863,7 @@ case 40: #line 237 "Svc_Conf.y" { ace_yyval.ident_ = 0; } break; -#line 862 "y.tab.c" +#line 866 "y.tab.c" } ace_yyssp -= ace_yym; ace_yystate = *ace_yyssp; diff --git a/ace/Thread.h b/ace/Thread.h index 1579dc4e29f..4880b824f8e 100644 --- a/ace/Thread.h +++ b/ace/Thread.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY diff --git a/ace/UPIPE_Acceptor.cpp b/ace/UPIPE_Acceptor.cpp index 9d3f97fcb77..2312869be0d 100644 --- a/ace/UPIPE_Acceptor.cpp +++ b/ace/UPIPE_Acceptor.cpp @@ -72,15 +72,19 @@ ACE_UPIPE_Acceptor::accept (ACE_UPIPE_Stream &new_stream, else { ACE_UPIPE_Stream *remote_stream = 0; - // Transfer address ownership. + + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, new_stream.lock_, -1)); + new_stream.set_handle (new_io.get_handle ()); + new_stream.reference_count_++; + // Transfer address ownership. new_io.get_local_addr (new_stream.local_addr_); new_io.get_remote_addr (new_stream.remote_addr_); - - // Now that we got the fd, we'll read the address of the + + // Now that we got the handle, we'll read the address of the // connector-side ACE_UPIPE_Stream out of the pipe and link that - // ACE_UPIPE_Stream to our ACE_UPIPE_Stream + // ACE_UPIPE_Stream to our ACE_UPIPE_Stream. if (ACE_OS::read (new_stream.get_handle (), (char *) &remote_stream, diff --git a/ace/UPIPE_Connector.cpp b/ace/UPIPE_Connector.cpp index f8e6cce603e..eeba0f7a8dd 100644 --- a/ace/UPIPE_Connector.cpp +++ b/ace/UPIPE_Connector.cpp @@ -43,10 +43,13 @@ ACE_UPIPE_Connector::connect (ACE_UPIPE_Stream &new_stream, #endif else // We're connected! { + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, new_stream.lock_, -1)); + ACE_UPIPE_Stream *ustream = &new_stream; new_stream.set_handle (handle); new_stream.remote_addr_ = addr; // class copy. + new_stream.reference_count_++; // Now send the address of our ACE_UPIPE_Stream over this pipe // to our corresponding ACE_UPIPE_Acceptor, so he may link the diff --git a/ace/UPIPE_Connector.h b/ace/UPIPE_Connector.h index 56fe8cb5b15..1e29b83270c 100644 --- a/ace/UPIPE_Connector.h +++ b/ace/UPIPE_Connector.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY diff --git a/ace/UPIPE_Stream.cpp b/ace/UPIPE_Stream.cpp index 3c9bed43494..b4bffcee7ae 100644 --- a/ace/UPIPE_Stream.cpp +++ b/ace/UPIPE_Stream.cpp @@ -13,6 +13,14 @@ ACE_ALLOC_HOOK_DEFINE(ACE_UPIPE_Stream) +ACE_UPIPE_Stream::ACE_UPIPE_Stream (void) + : remaining_ (0), + reference_count_ (0), + mb_last_ (0) +{ + ACE_TRACE ("ACE_UPIPE_Stream::ACE_UPIPE_STREAM"); +} + int ACE_UPIPE_Stream::control (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, void * val) @@ -31,14 +39,22 @@ int ACE_UPIPE_Stream::close (void) { ACE_TRACE ("ACE_UPIPE_Stream::close"); - // Since the UPIPE should have been closed earlier we won't bother - // checking to see if closing it now fails. + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); - if (this->ACE_SPIPE::get_handle () != ACE_INVALID_HANDLE) - this->ACE_SPIPE::close (); + this->reference_count_--; + + if (this->reference_count_ == 0) + { + // Since the UPIPE should have been closed earlier we won't bother + // checking to see if closing it now fails. - // Close down the ACE_stream. - return this->stream_.close (0); + if (this->ACE_SPIPE::get_handle () != ACE_INVALID_HANDLE) + this->ACE_SPIPE::close (); + + // Close down the ACE_stream. + return this->stream_.close (0); + } + return 0; } int @@ -73,7 +89,6 @@ ACE_UPIPE_Stream::send (const char *buffer, ACE_TRACE ("ACE_UPIPE_Stream::send"); ACE_Message_Block *mb_p; - ACE_NEW_RETURN (mb_p, ACE_Message_Block (n), -1); mb_p->copy (buffer, n); diff --git a/ace/UPIPE_Stream.h b/ace/UPIPE_Stream.h index 64313fcea99..d3e223bca07 100644 --- a/ace/UPIPE_Stream.h +++ b/ace/UPIPE_Stream.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY @@ -36,7 +35,10 @@ class ACE_Export ACE_UPIPE_Stream : public ACE_SPIPE friend class ACE_UPIPE_Acceptor; friend class ACE_UPIPE_Connector; public: - // = Termination. + + // = Initialization and Termination. + + ACE_UPIPE_Stream (void); int close (void); // Shut down the UPIPE and release resources. @@ -107,6 +109,15 @@ private: MT_Stream stream_; // Stream component used by the <UPIPE_Acceptor> and // <UPIPE_Connector> to link together two UPIPE_Streams. + + int reference_count_; + // Keep track of whether the sender and receiver have both shut + // down. + +#if defined (ACE_MT_SAFE) + ACE_Thread_Mutex lock_; + // Ensure that we are thread-safe. +#endif /* ACE_MT_SAFE */ }; #if defined (__ACE_INLINE__) diff --git a/ace/config-vxworks-ghs-1.8.h b/ace/config-vxworks-ghs-1.8.h index e478198fe2c..9204d3f60d1 100644 --- a/ace/config-vxworks-ghs-1.8.h +++ b/ace/config-vxworks-ghs-1.8.h @@ -40,7 +40,6 @@ #define ACE_LACKS_UCONTEXT_H #define ACE_LACKS_UTSNAME_T #define ACE_MT_SAFE -#define SIGNAL_SAFE_OS_CALLS // Defines the page size of the system. #define ACE_PAGE_SIZE 4096 diff --git a/ace/config-vxworks5.2-g++.h b/ace/config-vxworks5.2-g++.h index 3922136e172..deaeac7d28e 100644 --- a/ace/config-vxworks5.2-g++.h +++ b/ace/config-vxworks5.2-g++.h @@ -44,7 +44,6 @@ #define ACE_MT_SAFE #define ACE_TEMPLATES_REQUIRE_SOURCE #define ACE_TEMPLATES_REQUIRE_SPECIALIZATION -#define SIGNAL_SAFE_OS_CALLS // Defines the page size of the system. #define ACE_PAGE_SIZE 4096 diff --git a/ace/config-win32-msvc4.0.h b/ace/config-win32-msvc4.0.h index e6c49c327bd..bc0dcfa9f98 100644 --- a/ace/config-win32-msvc4.0.h +++ b/ace/config-win32-msvc4.0.h @@ -43,8 +43,21 @@ #include /**/ <windows.h> // if he's not doing MFC, snag this #endif +// Define the following two macros if you're compiling with WinSock 2.0. +// #define ACE_HAS_WINSOCK2 +// #define ACE_WSOCK_VERSION 2, 0 + +// Undefine the following macro if you're compiling with WinSock 2.0. +// Version 1.1 of WinSock +#define ACE_WSOCK_VERSION 1, 1 + // Needed for timeval. -#include /**/ <winsock.h> +#if defined (ACE_HAS_WINSOCK2) +#include /**/ <winsock2.h> +#include "ace/ws2tcpip.h" +#else +#include /**/ <winsock.h> +#endif /* ACE_HAS_WINSOCK2 */ #define ACE_HAS_UNICODE #define ACE_HAS_STL @@ -71,8 +84,6 @@ // Compiler doesn't support static data member templates. #define ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES -// Version 1.1 of WinSock -#define ACE_WSOCK_VERSION 1, 1 #define ACE_LACKS_RECVMSG #define ACE_LACKS_SENDMSG diff --git a/ace/ws2tcpip.h b/ace/ws2tcpip.h new file mode 100644 index 00000000000..45ecd2e6bf5 --- /dev/null +++ b/ace/ws2tcpip.h @@ -0,0 +1,86 @@ +/* +** WS2TCPIP.H - WinSock2 Extension for TCP/IP protocols +** +** This file contains TCP/IP specific information for use +** by WinSock2 compatible applications. +** +** To provide the backward compatibility, all the TCP/IP +** specific definitions that were included in the WINSOCK.H +** file are now included in WINSOCK2.H file. WS2TCPIP.H +** file includes only the definitions introduced in the +** "WinSock 2 Protocol-Specific Annex" document. +** +** Rev 0.3 Nov 13, 1995 +*/ + +#ifndef _WS2TCPIP_H_ +#define _WS2TCPIP_H_ + +/* Structure to keep interface specific information */ + +typedef struct _INTERFACE_INFO +{ + u_long iiFlags; /* Interface flags */ + struct sockaddr iiAddress; /* Interface address */ + struct sockaddr iiBroadcastAddress; /* Broadcast address */ + struct sockaddr iiNetmask; /* Network mask */ +} INTERFACE_INFO; + +/* Possible flags for the iiFlags - bitmask */ + +#define IFF_UP 0x00000001 /* Interface is up */ +#define IFF_BROADCAST 0x00000002 /* Broadcast is supported */ +#define IFF_LOOPBACK 0x00000004 /* this is loopback interface */ +#define IFF_POINTTOPOINT 0x00000008 /*this is point-to-point +interface*/ +#define IFF_MULTICAST 0x00000010 /* multicast is supported */ + +/* Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP */ + +struct ip_mreq { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_interface; /* local IP address of interface */ +}; + +/* TCP/IP specific Ioctl codes */ + +#define SIO_GET_INTERFACE_LIST <TBD> + +/* Option to use with [gs]etsockopt at the IPPROTO_IP level */ + +#define IP_OPTIONS 1 /* set/get IP options */ +#define IP_HDRINCL 2 /* header is included with data */ +#define IP_TOS 3 /* IP type of service and preced*/ +#define IP_TTL 4 /* IP time to live */ +#define IP_MULTICAST_IF 9 /* set/get IP multicast i/f */ +#define IP_MULTICAST_TTL 10 /* set/get IP multicast ttl */ +#define IP_MULTICAST_LOOP 11 /*set/get IP multicast loopback */ +#define IP_ADD_MEMBERSHIP 12 /* add an IP group membership */ +#define IP_DROP_MEMBERSHIP 13/* drop an IP group membership */ + + +/* Option to use with [gs]etsockopt at the IPPROTO_UDP level */ + +#define UDP_NOCHECKSUM 1 + +/* Option to use with [gs]etsockopt at the IPPROTO_TCP level */ + +#define TCP_EXPEDITED_1122 0x0002 + + +/* IPv6 definitions */ + +struct in_addr6 { + u_char s6_addr[16]; /* IPv6 address */ +}; + +struct sockaddr_in6 { + short sin6_family; /* AF_INET6 */ + u_short sin6_port; /* Transport level port numb +er */ + u_long sin6_flowinfo; /* IPv6 flow information */ + struct in_addr6 sin6_addr; /* IPv6 address */ +}; + + +#endif /* _WS2TCPIP_H_ */ diff --git a/examples/ASX/Event_Server/Event_Server/event_server.cpp b/examples/ASX/Event_Server/Event_Server/event_server.cpp index 763bc76d03b..ef88ac22853 100644 --- a/examples/ASX/Event_Server/Event_Server/event_server.cpp +++ b/examples/ASX/Event_Server/Event_Server/event_server.cpp @@ -1,6 +1,7 @@ -// Test the event server. // $Id$ +// Test the event server. + #include "ace/Log_Msg.h" #include "ace/Stream.h" #include "ace/Service_Config.h" diff --git a/netsvcs/ACE-netsvcs.html b/netsvcs/ACE-netsvcs.html index 5b1200a15d4..f631d1986e4 100644 --- a/netsvcs/ACE-netsvcs.html +++ b/netsvcs/ACE-netsvcs.html @@ -46,12 +46,12 @@ These services play two roles in ACE:<P> </UL> The heart of the ACE network services is the <A -HREF="http://www.cs.wustl.edu/~schmidt/ACE-papers#config">Service +HREF="http://www.cs.wustl.edu/~schmidt/ACE-papers.html#config">Service Configurator</A>, which is an object-oriented framework that automates the configuration and reconfiguration of multi-service daemons. All the ACE network services are configured using the Service Configurator. Please refer to the <A -HREF="NETSVC-INSTALL.html">online documentation</a> for more +HREF="http://www.cs.wustl.edu/~schmidt/NETSVC-INSTALL.html">online documentation</a> for more information on installing and testing the ACE network services.<P> <P><HR> diff --git a/performance-tests/Synch-Benchmarks/svc.conf b/performance-tests/Synch-Benchmarks/svc.conf index 4504968908e..45a6a49d4b8 100644 --- a/performance-tests/Synch-Benchmarks/svc.conf +++ b/performance-tests/Synch-Benchmarks/svc.conf @@ -1,5 +1,6 @@ # Dynamically configure all the tests dynamic Mutex_Test Service_Object * .shobj/mutex_test.so:mutex_test() +dynamic Mutex_Test Service_Object * .shobj/mutex_test.so:mutex_test() dynamic Semaphore_Test Service_Object * .shobj/sema_test.so:sema_test() dynamic Recursive_Lock_Test Service_Object * .shobj/recursive_lock_test.so:recursive_lock_test() dynamic RWRD_Mutex_Test Service_Object * .shobj/rwrd_test.so:rwrd_test() diff --git a/performance-tests/Synch-Benchmarks/synch_driver.cpp b/performance-tests/Synch-Benchmarks/synch_driver.cpp index 8520fef85dc..e4412022e7a 100644 --- a/performance-tests/Synch-Benchmarks/synch_driver.cpp +++ b/performance-tests/Synch-Benchmarks/synch_driver.cpp @@ -20,33 +20,18 @@ public: private: void run_test (void); - virtual int handle_signal (int signum -#if defined (ACE_HAS_SIGINFO_T) -, siginfo_t * = 0, ucontext_t * = 0 -#endif /* ACE_HAS_SIGINFO_T */ -); - int n_lwps_; int orig_n_lwps_; + ACE_Sig_Adapter done_; }; -int -Benchmark_Test::handle_signal (int signum -#if defined (ACE_HAS_SIGINFO_T) -, siginfo_t *, ucontext_t * -#endif /* ACE_HAS_SIGINFO_T */ -) -{ - ACE_DEBUG ((LM_DEBUG, "caught %S, shutting down the test%a\n", signum, 1)); - return 0; -} - Benchmark_Test::Benchmark_Test (void) : ACE_Service_Config (1), // Do not load default services n_lwps_ (0), - orig_n_lwps_ (0) + orig_n_lwps_ (0), + done_ (ACE_Sig_Handler_Ex (ACE_Service_Config::end_reactor_event_loop)) { - ACE_Service_Config::reactor ()->register_handler (SIGINT, this); + ACE_Service_Config::reactor ()->register_handler (SIGINT, &this->done_); } void @@ -63,9 +48,11 @@ Benchmark_Test::run_test (void) ACE_DEBUG ((LM_DEBUG, "starting timer\n")); options.start_timer (); - ACE_OS::select (0, 0, 0, 0, &timeout); + // Use Reactor as a timer (which can be interrupted by a signal). + ACE_Service_Config::run_reactor_event_loop (timeout); + options.stop_timer (); - ACE_DEBUG ((LM_DEBUG, "stopping timer\n")); + ACE_DEBUG ((LM_DEBUG, "\nstopping timer\n")); // Stop thread(s) from making any further progress. ACE_Service_Config::thr_mgr ()->suspend_all (); diff --git a/tests/UPIPE_SAP_Test.cpp b/tests/UPIPE_SAP_Test.cpp index 0b38ecd7d39..2cd62cd4b9e 100644 --- a/tests/UPIPE_SAP_Test.cpp +++ b/tests/UPIPE_SAP_Test.cpp @@ -29,21 +29,21 @@ // Global pattern static ACE_UPIPE_Addr addr ("pattern"); -// client thread. +// connector thread. static void * -client (void *) +connector (void *) { // Insert thread into thr_mgr. ACE_NEW_THREAD; ACE_UPIPE_Stream c_stream; - ACE_DEBUG ((LM_DEBUG, "(%t) client starting connect\n")); + ACE_DEBUG ((LM_DEBUG, "(%t) connector starting connect\n")); ACE_UPIPE_Connector con; if (con.connect (c_stream, addr) == -1) - ACE_DEBUG ((LM_DEBUG, "(%t) client ACE_UPIPE_Connector failed\n")); + ACE_DEBUG ((LM_DEBUG, "(%t) connector ACE_UPIPE_Connector failed\n")); ACE_Message_Block *mb; @@ -52,10 +52,10 @@ client (void *) mb->copy ("hello"); if (c_stream.send (mb) == -1) - ACE_DEBUG ((LM_DEBUG, "(%t) error client send\n")); + ACE_DEBUG ((LM_DEBUG, "(%t) error connector send\n")); if (c_stream.recv (mb) == -1) - ACE_DEBUG ((LM_DEBUG, "(%t) error client recv\n")); + ACE_DEBUG ((LM_DEBUG, "(%t) error connector recv\n")); ACE_ASSERT (ACE_OS::strcmp (mb->rd_ptr (), "thanks") == 0); @@ -63,12 +63,12 @@ client (void *) delete mb; // Now try the send()/recv() interface. - char mytext[] = "This string is sent by client as a buffer"; + char mytext[] = "This string is sent by connector as a buffer"; - ACE_DEBUG ((LM_DEBUG, "(%t) client sending text\n")); + ACE_DEBUG ((LM_DEBUG, "(%t) connector sending text\n")); if (c_stream.send (mytext, sizeof mytext) == -1) ACE_DEBUG ((LM_DEBUG, - "(%t) buffer send from client failed\n")); + "(%t) buffer send from connector failed\n")); char conbuf[BUFSIZ]; // Buffer to receive response. @@ -78,14 +78,15 @@ client (void *) { if (c_stream.recv (&c, 1) == -1) ACE_DEBUG ((LM_DEBUG, - "(%t) buffer recv from client failed\n")); + "(%t) buffer recv from connector failed\n")); else conbuf[i] = c; } conbuf[i] = '\0'; ACE_DEBUG ((LM_DEBUG, "(%t) conbuf = %s", conbuf)); - ACE_ASSERT (ACE_OS::strcmp (conbuf, "this is the server response!") == 0); + ACE_ASSERT (ACE_OS::strcmp (conbuf, "this is the acceptor response!") == 0); + ACE_ASSERT (ACE_OS::strcmp (conbuf, "this is the acceptor response!") == 0); c_stream.close (); ACE_DEBUG ((LM_DEBUG, "\n(%t) exiting thread\n")); @@ -93,15 +94,24 @@ client (void *) } static void * -server (void *args) +acceptor (void *args) { // Insert thread into thr_mgr. ACE_NEW_THREAD; ACE_UPIPE_Acceptor *acceptor = (ACE_UPIPE_Acceptor *) args; ACE_UPIPE_Stream s_stream; + ACE_hthread_t thr_handle; - ACE_DEBUG ((LM_DEBUG, "(%t) server starting accept\n")); + // Spawn a connector thread. + if (ACE_Thread::spawn (ACE_THR_FUNC (connector), + (void *) 0, + THR_NEW_LWP | THR_DETACHED, + 0, + &thr_handle) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), 0); + + ACE_DEBUG ((LM_DEBUG, "(%t) acceptor starting accept\n")); if (acceptor->accept (s_stream) == -1) ACE_DEBUG ((LM_DEBUG, @@ -110,7 +120,7 @@ server (void *args) ACE_Message_Block *mb = 0; if (s_stream.recv (mb) == -1) - ACE_DEBUG ((LM_DEBUG, "(%t) server recv failed\n")); + ACE_DEBUG ((LM_DEBUG, "(%t) acceptor recv failed\n")); ACE_ASSERT (ACE_OS::strcmp (mb->rd_ptr (), "hello") == 0); @@ -118,28 +128,27 @@ server (void *args) mb->copy ("thanks"); if (s_stream.send (mb) == -1) - ACE_DEBUG ((LM_DEBUG, "(%t) server send failed\n")); + ACE_DEBUG ((LM_DEBUG, "(%t) acceptor send failed\n")); char s_buf[BUFSIZ]; - ACE_DEBUG ((LM_DEBUG, "(%t) server sleeping on recv\n")); + ACE_DEBUG ((LM_DEBUG, "(%t) acceptor sleeping on recv\n")); if (s_stream.recv (s_buf, sizeof s_buf) == -1) - ACE_DEBUG ((LM_DEBUG, "(%t) server recv failed\n")); + ACE_DEBUG ((LM_DEBUG, "(%t) acceptor recv failed\n")); else ACE_ASSERT (ACE_OS::strcmp (s_buf, - "This string is sent by client as a buffer") == 0); + "This string is sent by connector as a buffer") == 0); - const char svr_response[] = "this is the server response!"; + const char svr_response[] = "this is the acceptor response!"; ACE_OS::strcpy (s_buf, svr_response); if (s_stream.send (s_buf, sizeof svr_response) == -1) - ACE_DEBUG ((LM_DEBUG, "(%t) server send failed\n")); + ACE_DEBUG ((LM_DEBUG, "(%t) acceptor send failed\n")); s_stream.close (); ACE_DEBUG ((LM_DEBUG, "(%t) exiting thread\n")); return 0; } - #endif /* ACE_HAS_THREADS */ int @@ -148,33 +157,30 @@ main (int, char *argv[]) ACE_START_TEST ("UPIPE_SAP_Test.cpp"); #if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_STREAM_PIPES) || defined (ACE_WIN32)) - - ACE_hthread_t thr_handle_server; - ACE_hthread_t thr_handle_client; - + ACE_hthread_t thr_handle_acceptor; + ACE_hthread_t thr_handle_connector; ACE_UPIPE_Acceptor acceptor (addr); - // Spawn a server thread. - if (ACE_Thread::spawn (ACE_THR_FUNC (server), + // Spawn a acceptor thread. + if (ACE_Thread::spawn (ACE_THR_FUNC (acceptor), (void *) &acceptor, THR_NEW_LWP | THR_DETACHED, 0, - &thr_handle_server) == -1) + &thr_handle_acceptor) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), 1); - // Spawn a client thread. - if (ACE_Thread::spawn (ACE_THR_FUNC (client), + // Spawn a connector thread. + if (ACE_Thread::spawn (ACE_THR_FUNC (connector), (void *) 0, THR_NEW_LWP | THR_DETACHED, 0, - &thr_handle_client) == -1) + &thr_handle_connector) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), 1); - // Wait for server and client threads to exit. - ACE_Thread::join (thr_handle_client); - ACE_Thread::join (thr_handle_server); - + // Wait for both the acceptor and connector threads to exit. + ACE_Thread::join (thr_handle_connector); + ACE_Thread::join (thr_handle_acceptor); #else ACE_ERROR ((LM_ERROR, "threads and/or UPIPE not supported on this platform\n")); #endif /* ACE_HAS_THREADS */ |