diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1996-11-28 07:14:18 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1996-11-28 07:14:18 +0000 |
commit | ad66c757e62495734e28c3f3bbc33a9fd29217d3 (patch) | |
tree | b679cecc050588c642722e7dffd780ed81a442eb | |
parent | d395a38d42932c86ebef82468f58c03b3529363e (diff) | |
download | ATCD-ad66c757e62495734e28c3f3bbc33a9fd29217d3.tar.gz |
yow
39 files changed, 654 insertions, 320 deletions
diff --git a/ChangeLog-96b b/ChangeLog-96b index fbc3191defa..2971c7e6dc6 100644 --- a/ChangeLog-96b +++ b/ChangeLog-96b @@ -1,5 +1,131 @@ +Thu Nov 28 00:53:16 1996 Douglas C. Schmidt <schmidt@lambada.cs.wustl.edu> + + * tests/CPP_Test.cpp: Completely reworked this test so that it + should run correctly on Win32 and UNIX. + +Wed Nov 27 16:50:17 1996 Douglas C. Schmidt <schmidt@lambada.cs.wustl.edu> + + * Put out a new beta of ACE 4.0.33. + + * tests/Mutex_Test.cpp (test): Fixed the test() function so that + it doesn't use the ACE_Thread_Control unless we explicitly want + to use threads. + + * tests/test_config.h: Added addition information about the + process id and thread id of the main thread. + + * ace/Synch.h: Speed things up a bit by conditionally #including + "ace/SV_Semaphore_Complex.h" only if we are compiling on a + non-Win32 platform or a POSIX platform. Thanks to Matthias + Kerkhoff <make@cs.tu-berlin.de> for this. + + * ace/SV_Semaphore_Complex.h: Incorporated the new ACE_USING + macro, which is useful if you have + + class b { + a() + }; + + class d : private b { + b::a() // still works, but depriciated + using b::a() // should be used instead + }; + + Thanks to Matthias Kerkhoff <make@cs.tu-berlin.de> for this. + + * ace/OS.h: Added a new macro called ACE_USING, which is used to + distinguish between platforms that support namespace "using" + semantics and those that don't. Thanks to Matthias Kerkhoff + <make@cs.tu-berlin.de> for this. + + * examples/Misc/test_XtReactor[12].cpp: Had to add the infamous + #define String XtString before including Xm/PushB.h. Also, there + were some references to XtReactor when the class is now + ACE_XtReactor. Thanks to Gonzalo Diethelm <gonzo@ing.puc.cl> + for reporting this. + + * ace/XtReactor.cpp (ACE_XtReactor): timeout_ was not being + initialized on the constructor, and that caused a core dump. + Thanks to Gonzalo Diethelm <gonzo@ing.puc.cl> for reporting + this. + + * ace/SOCK.h: Put the open() call in the protected part of the + class since we generally don't want clients to call this + directly. Thanks to Eric Newton <ecn@clark.net> for pointing + this out. + + * ace/ACE.cpp: Fixed a bug where sin.sin_family was being set + rather than sin.sin_len. Thanks to Chuck Gehr + <gehr@sweng.stortek.com> for reporting this. + + * ace/ACE.cpp: Enhanced the ACE::{send_n,recv_n} methods so that + they check to see if errno == EWOULDBLOCK when ACE_OS::send() or + ACE_OS::recv() returns -1. If that's the case, then they keep + iterating. + + Thanks to Mehdi TABATABAI <Mehdi.TABATABAI@ed.gva.sita.int> for + this suggestion. + + * ace/Log_Msg.h: Fixed ACE_RETURN so that it only has 1 parameter + if ACE_NLOGGING is enabled. Thanks to Antonio Tortorici + <antonio@rh0011.roma.tlsoft.it> for reporting this. + + * ace/config-vxworks*.h: Added ACE_NTRACE macros so that + tracing doesn't magically turn on! + + * ace/Task.cpp (activate): the &ACE_Task_Base::svc_run() argument + needs a cast to ACE_THR_FUNC, because that's what + ACE_Thread_Manager::spawn_n() requires. On VxWorks, + ACE_THR_FUNC functions return an int, while svc_run() returns + void *. Thanks to David Levine for this. + + * ace/Thread_Manager.cpp (kill_thr): I was mistakenly passing in + the thr_handle_ where I should have been passing in the thr_id_. + In addition, made sure we don't set errno to the wrong value... + Thanks to Ross Dargahi <rossd@acm.org> for reporting this. + + * ace/{Synch_T,Synch}.h: If we don't actually own the lock + anymore, don't try to do a release. Thanks to Jonathan Biggar + <jon@sems.com> for reporting this bug. + + * ace/ACE.cpp (handle_timed_complete): Added an ex_handles mask so + that non-blocking connects will work correctly on Win32. Thanks + to Antonio Tortorici <antonio@rh0011.roma.tlsoft.it> for + reporting this fix. + + * ace/Message_Queue.h: Updated the documentation to stress the + fact that the timeouts are specified in *absolute* time, rather + than in relative time. Thanks to Bob Dunmire <bobd@titan.com> + for reporting this. + + * tests/test_config.h: Modified the ACE_END_TEST macro so that the + log file is closed. This works around a problem on VxWorks + where destructors of static objects don't get closed + automatically. Thanks to David Levine for this fix. + + * ace/OS.i (rand_r): Added a fix for Digital UNIX so that rand_r + works correctly in MT settings. Thanks to Thilo Kielmann + <kielmann@informatik.uni-siegen.de> for this. + +Wed Nov 27 16:12:00 1996 Tim H. Harrison <harrison@lambada.cs.wustl.edu> + + * ace/Stream.cpp: Fixed a bug in ACE_Stream::open to + allow applications to specify a tail or a head without + having to specify both. This was needed by the ACE_Pipeline + application since it only needs a Pipeline-specific tail + (not a head). + Tue Nov 26 18:00:25 1996 Douglas C. Schmidt <schmidt@lambada.cs.wustl.edu> + * ace: Functions should not be declared with ACE_INLINE in a + .cpp file. Fixed this problem in the following files: + + SPIPE_Acceptor.cpp:116:ACE_INLINE + TLI_Acceptor.cpp:145:ACE_INLINE int + TLI_Acceptor.cpp:192:ACE_INLINE + Task.cpp:121:ACE_INLINE int + Task.cpp:130:ACE_INLINE void + * ace/{OS,Thread}: Added Chuck Gehr's suggested change for the pthread_keycreate() routine, which must take extern "C" functions on MVC C++. This fix isn't perfect, but it should @@ -4087,5 +4213,3 @@ Mon Jul 1 02:15:34 1996 Tim H. Harrison (harrison@lambada.cs.wustl.edu) ACE_Reactor. This is so Reactor, ReactorEx, and Proactor can all reuse the calculations required by the Timer_Queue without duplicating code. - - @@ -663,6 +663,7 @@ Hanan Herzog <hanan@wallenda.stanford.edu> Eric Parker <eparker@credence.com> James Michael Dwyer <jdwyer@knox.edu> Arun Katkere <katkere@praja.com> +Bob Dunmire <bobd@titan.com> 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/ACE.cpp b/ace/ACE.cpp index f3f88f79ef2..5445829bc32 100644 --- a/ace/ACE.cpp +++ b/ace/ACE.cpp @@ -226,27 +226,76 @@ ACE::send_n (ACE_HANDLE handle, const void *buf, size_t len) { ACE_TRACE ("ACE::send_n"); size_t bytes_written; - int n; + ssize_t n; for (bytes_written = 0; bytes_written < len; bytes_written += n) - if ((n = ACE::send (handle, (const char *) buf + bytes_written, - len - bytes_written)) == -1) - return -1; + { + n = ACE::send (handle, (const char *) buf + bytes_written, + len - bytes_written); + if (n == -1) + { + if (errno != EWOULDBLOCK) + return -1; + else + n = 0; // Keep trying to send. + } + } return bytes_written; } ssize_t -ACE::send_n (ACE_HANDLE handle, const void *buf, size_t len, int flags) +ACE::send_n (ACE_HANDLE handle, + const void *buf, + size_t len, + int flags) { ACE_TRACE ("ACE::send_n"); size_t bytes_written; - int n; + ssize_t n; for (bytes_written = 0; bytes_written < len; bytes_written += n) - if ((n = ACE_OS::send (handle, (const char *) buf + bytes_written, - len - bytes_written, flags)) == -1) - return -1; + { + n = ACE_OS::send (handle, (const char *) buf + bytes_written, + len - bytes_written, flags); + + if (n == -1) + { + if (errno != EWOULDBLOCK) + return -1; + else + n = 0; // Keep trying to send. + } + } + + return bytes_written; +} + +// Receive <len> bytes into <buf> from <handle> (uses the <write> +// system call on UNIX and the <WriteFile> call on Win32). + +ssize_t +ACE::write_n (ACE_HANDLE handle, + const void *buf, + size_t len) +{ + ACE_TRACE ("ACE::write_n"); + + size_t bytes_written; + ssize_t n; + + for (bytes_written = 0; bytes_written < len; bytes_written += n) + { + n = ACE_OS::write (handle, (const char *) buf + bytes_written, + len - bytes_written); + if (n == -1) + { + if (errno != EWOULDBLOCK) + return -1; + else + n = 0; // Keep trying to send. + } + } return bytes_written; } @@ -256,15 +305,22 @@ ACE::recv_n (ACE_HANDLE handle, void *buf, size_t len) { ACE_TRACE ("ACE::recv_n"); size_t bytes_read; - int n; + ssize_t n; for (bytes_read = 0; bytes_read < len; bytes_read += n) - if ((n = ACE::recv (handle, (char *) buf + bytes_read, - len - bytes_read)) == -1) - return -1; - else if (n == 0) - break; + { + n = ACE::recv (handle, (char *) buf + bytes_read, len - bytes_read); + if (n == -1) + { + if (errno != EWOULDBLOCK) + return -1; + else + n = 0; // Keep trying to read. + } + else if (n == 0) + break; + } return bytes_read; } @@ -273,20 +329,29 @@ ACE::recv_n (ACE_HANDLE handle, void *buf, size_t len, int flags) { ACE_TRACE ("ACE::recv_n"); size_t bytes_read; - int n; + ssize_t n; for (bytes_read = 0; bytes_read < len; bytes_read += n) - if ((n = ACE_OS::recv (handle, (char *) buf + bytes_read, - len - bytes_read, flags)) == -1) - return -1; - else if (n == 0) - break; + { + n = ACE::recv (handle, (char *) buf + bytes_read, len - bytes_read, flags); + + if (n == -1) + { + if (errno != EWOULDBLOCK) + return -1; + else + n = 0; // Keep trying to read. + } + else if (n == 0) + break; + } return bytes_read; } - // Receive <len> bytes into <buf> from <handle> (uses the <read> - // system call on UNIX and the <ReadFile> call on Win32). +// Receive <len> bytes into <buf> from <handle> (uses the <read> +// system call on UNIX and the <ReadFile> call on Win32). + ssize_t ACE::read_n (ACE_HANDLE handle, void *buf, @@ -295,37 +360,24 @@ ACE::read_n (ACE_HANDLE handle, ACE_TRACE ("ACE::read_n"); size_t bytes_read; - int n; + ssize_t n; for (bytes_read = 0; bytes_read < len; bytes_read += n) - if ((n = ACE_OS::read (handle, (char *) buf + bytes_read, - len - bytes_read)) == -1) - return -1; - else if (n == 0) - break; - - return bytes_read; -} - -// Receive <len> bytes into <buf> from <handle> (uses the <write> -// system call on UNIX and the <WriteFile> call on Win32). - -ssize_t -ACE::write_n (ACE_HANDLE handle, - const void *buf, - size_t len) -{ - ACE_TRACE ("ACE::write_n"); - - size_t bytes_written; - int n; + { + n = ACE_OS::read (handle, (char *) buf + bytes_read, len - bytes_read); - for (bytes_written = 0; bytes_written < len; bytes_written += n) - if ((n = ACE_OS::write (handle, (const char *) buf + bytes_written, - len - bytes_written)) == -1) - return -1; + if (n == -1) + { + if (errno != EWOULDBLOCK) + return -1; + else + n = 0; // Keep trying to read. + } + else if (n == 0) + break; + } - return bytes_written; + return bytes_read; } // Format buffer into printable format. This is useful for debugging. @@ -460,13 +512,26 @@ ACE::handle_timed_complete (ACE_HANDLE h, ACE_Handle_Set rd_handles; ACE_Handle_Set wr_handles; +#if defined (ACE_WIN32) + ACE_Handle_Set ex_handles; + ex_handles.set_bit (h); +#endif /* ACE_WIN32 */ rd_handles.set_bit (h); wr_handles.set_bit (h); +#if defined (ACE_WIN32) + int n = ACE_OS::select (int (h) + 1, + rd_handles, + wr_handles, + ex_handles, + timeout); +#else int n = ACE_OS::select (int (h) + 1, rd_handles, wr_handles, 0, timeout); +#endif /* ACE_WIN32 */ + // If we failed to connect within the time period allocated by the // caller, then we fail (e.g., the remote host might have been too // busy to accept our call). @@ -479,11 +544,13 @@ ACE::handle_timed_complete (ACE_HANDLE h, // Check if the handle is ready for reading and the handle is *not* // ready for writing, which may indicate a problem. But we need to // make sure... -#if defined (ACE_HAS_TLI) +#if defined (ACE_WIN32) + else if (rd_handles.is_set (h) || ex_handles.is_set (h)) +#elif defined (ACE_HAS_TLI) else if (rd_handles.is_set (h) && !wr_handles.is_set (h)) #else else if (rd_handles.is_set (h)) -#endif /* ACE_HAS_TLI */ +#endif /* ACE_WIN32 */ { char dummy; // The following recv() won't block provided that the @@ -597,7 +664,7 @@ ACE::bind_port (ACE_HANDLE handle) ACE_OS::memset ((void *) &sin, 0, sizeof sin); sin.sin_family = AF_INET; #if defined (ACE_HAS_SIN_LEN) - sin.sin_family = sizeof sin; + sin.sin_len = sizeof sin; #endif /* ACE_HAS_SIN_LEN */ sin.sin_addr.s_addr = INADDR_ANY; diff --git a/ace/ACE.h b/ace/ACE.h index 07410b481df..e9441a3b44b 100644 --- a/ace/ACE.h +++ b/ace/ACE.h @@ -61,6 +61,23 @@ public: // out a -1 is returned with <errno == ETIME>. If it succeeds the // number of bytes received is returned. + // = Network I/O functions that recv and send exactly n bytes. + static ssize_t recv_n (ACE_HANDLE handle, + void *buf, + size_t len, + int flags); + // Receive <len> bytes into <buf> from <handle> (uses the <recv> + // call). If <handle> is set to non-blocking mode this call will + // poll until all <len> bytes are received. + + static ssize_t recv_n (ACE_HANDLE handle, + void *buf, + size_t len); + // Receive <len> bytes into <buf> from <handle> (uses the <read> + // system call on UNIX and the <recv> call on Win32). If <handle> + // is set to non-blocking mode this call will poll until all <len> + // bytes are received. + static ssize_t recv_n (ACE_HANDLE handle, void *buf, size_t len, @@ -81,13 +98,35 @@ public: static ssize_t send (ACE_HANDLE handle, const void *buf, + size_t len); + // Send up to <len> bytes into <buf> from <handle> (uses the <write> + // system call on UNIX and the <send> call on Win32). + + static ssize_t send_n (ACE_HANDLE handle, + const void *buf, + size_t len, + int flags); + // Send <len> bytes from <buf> to <handle> (uses the <send> system + // call). If <handle> is set to non-blocking mode this call will + // poll until all <len> bytes are sent. + + static ssize_t send_n (ACE_HANDLE handle, + const void *buf, + size_t len); + // Send <len> bytes from <buf> to <handle> (uses the <write> system + // call on UNIX and the <recv> call on Win32). If <handle> is set + // to non-blocking mode this call will poll until all <len> bytes + // are sent. + + static ssize_t send (ACE_HANDLE handle, + const void *buf, size_t len, int flags, const ACE_Time_Value *timeout); // Wait to to <timeout> amount of time to send up to <len> bytes // into <buf> from <handle> (uses the <send> call). If <send> times // out a -1 is returned with <errno == ETIME>. If it succeeds the - // number of bytes sent is returned. + // number of bytes sent is returned. static ssize_t send_n (ACE_HANDLE handle, const void *buf, @@ -100,51 +139,22 @@ public: // If a timeout does not occur, <send_n> return <len> (i.e., the // number of bytes requested to be sent). - static ssize_t send (ACE_HANDLE handle, - const void *buf, - size_t len); - // Send up to <len> bytes into <buf> from <handle> (uses the <write> - // system call on UNIX and the <send> call on Win32). - - // = Network I/O functions that recv and send exactly n bytes. - static ssize_t recv_n (ACE_HANDLE handle, - void *buf, - size_t len, - int flags); - // Receive <len> bytes into <buf> from <handle> (uses the <recv> - // call). - - static ssize_t recv_n (ACE_HANDLE handle, - void *buf, - size_t len); - // Receive <len> bytes into <buf> from <handle> (uses the <read> - // system call on UNIX and the <recv> call on Win32). - - static ssize_t send_n (ACE_HANDLE handle, - const void *buf, - size_t len, - int flags); - // Send <len> bytes from <buf> to <handle> (uses the <send> system - // call). - - static ssize_t send_n (ACE_HANDLE handle, - const void *buf, - size_t len); - // Send <len> bytes from <buf> to <handle> (uses the <write> system - // call on UNIX and the <recv> call on Win32). - // = File system I/O functions that encapsulate differences between UNIX and Win32 and also send and recv exactly n bytes. static ssize_t read_n (ACE_HANDLE handle, void *buf, size_t len); // Receive <len> bytes into <buf> from <handle> (uses the <read> - // system call on UNIX and the <ReadFile> call on Win32). + // system call on UNIX and the <ReadFile> call on Win32). If + // <handle> is set to non-blocking mode this call will poll until + // all <len> bytes are received. static ssize_t write_n (ACE_HANDLE handle, const void *buf, size_t len); // Send <len> bytes from <buf> to <handle> (uses the <write> system - // call on UNIX and the <WriteFile> call on Win32). + // call on UNIX and the <WriteFile> call on Win32). If <handle> is + // set to non-blocking mode this call will poll until all <len> + // bytes are sent. // = Functions that perform useful behavior related to establishing // socket connections active and passively. diff --git a/ace/INET_Addr.cpp b/ace/INET_Addr.cpp index 5a98da7ce94..18d17b1dd38 100644 --- a/ace/INET_Addr.cpp +++ b/ace/INET_Addr.cpp @@ -1,7 +1,7 @@ // INET_Addr.cpp // $Id$ -/* Defines the Internet domain address family address format. */ +// Defines the Internet domain address family address format. #define ACE_BUILD_DLL #include "ace/INET_Addr.h" diff --git a/ace/Log_Msg.h b/ace/Log_Msg.h index 5af0a8f5349..71d1d98e204 100644 --- a/ace/Log_Msg.h +++ b/ace/Log_Msg.h @@ -34,7 +34,7 @@ #if defined (ACE_NLOGGING) #define ACE_HEX_DUMP(X) -#define ACE_RETURN(ERROR, Y) do { errno = ERROR, return (Y); } while (0) +#define ACE_RETURN(Y) do { return (Y); } while (0) #define ACE_ERROR_RETURN(X, Y) return (Y) #define ACE_ERROR_BREAK(X) { break; } #define ACE_ERROR(X) diff --git a/ace/Message_Queue.h b/ace/Message_Queue.h index b91a56fda1a..73fa40f3108 100644 --- a/ace/Message_Queue.h +++ b/ace/Message_Queue.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY @@ -33,11 +32,11 @@ class ACE_Message_Queue_Reverse_Iterator; template <ACE_SYNCH_1> class ACE_Message_Queue // = TITLE - // A thread-safe message queueing facility, modeled after the - // queueing facilities in System V StreamS. + // A threaded message queueing facility, modeled after the + // queueing facilities in System V STREAMs. // // = DESCRIPTION - // A ACE_Message_Queue is the central queueing facility for + // An <ACE_Message_Queue> is the central queueing facility for // messages in the ASX framework. If <ACE_SYNCH_1> is // ACE_MT_SYNCH then all operations are thread-safe. Otherwise, // if it's <ACE_NULL_SYNCH> then there's no locking overhead. @@ -46,9 +45,9 @@ friend class ACE_Message_Queue_Iterator<ACE_SYNCH_2>; friend class ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_2>; public: + // = Traits typedef ACE_Message_Queue_Iterator<ACE_SYNCH_2> ITERATOR; typedef ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_2> REVERSE_ITERATOR; - // Traits // = Default high and low water marks. enum @@ -82,11 +81,7 @@ public: // Returns -1 on failure, else the number of items still on the // queue. - // = For all the following three routines if tv == 0, the caller - // will block until action is possible, else will wait for amount of - // time in *tv). Calls will return, however, when queue is closed, - // deactivated, when a signal occurs, or if the time specified in tv - // elapses, (in which case errno = EWOULDBLOCK). + // = For all the following three routines if tv == 0, the caller will block until action is possible, else will wait until the absolute time specified in *tv elapses). Calls will return, however, when queue is closed, deactivated, when a signal occurs, or if the time specified in tv elapses, (in which case errno = EWOULDBLOCK). int enqueue (ACE_Message_Block *new_item, ACE_Time_Value *tv = 0); // Enqueue an <ACE_Message_Block *> into the <Message_Queue> in @@ -156,8 +151,7 @@ public: // Declare the dynamic allocation hooks. protected: - // = Routines that actually do the enqueueing and dequeueing (these - // assume that locks are held by the corresponding public methods). + // = Routines that actually do the enqueueing and dequeueing (these assume that locks are held by the corresponding public methods). int enqueue_i (ACE_Message_Block *new_item); // Enqueue an <ACE_Message_Block *> in accordance with its priority. @@ -178,8 +172,7 @@ protected: int is_empty_i (void); // True if queue is empty, else false. - // = Implementation of the public activate() and deactivate() - // methods above (assumes locks are held). + // = Implementation of the public activate() and deactivate() methods above (assumes locks are held). int deactivate_i (void); // Deactivate the queue. int activate_i (void); @@ -220,9 +213,7 @@ protected: template <ACE_SYNCH_1> class ACE_Message_Queue_Iterator // = TITLE - // Iterator for the ACE_Message_Queue. - // - // = DESCRIPTION + // Iterator for the <ACE_Message_Queue>. { public: // = Initialization method. @@ -253,9 +244,7 @@ private: template <ACE_SYNCH_1> class ACE_Message_Queue_Reverse_Iterator // = TITLE - // Reverse Iterator for the ACE_Message_Queue. - // - // = DESCRIPTION + // Reverse Iterator for the <ACE_Message_Queue>. { public: // = Initialization method. @@ -106,6 +106,12 @@ // Here are all ACE-specific global declarations needed throughout // ACE. +#if defined (ACE_HAS_USING_KEYWORD) +#define ACE_USING using +#else +#define ACE_USING +#endif /* ACE_HAS_USING_KEYWORD */ + // Helpful dump macros. #define ACE_BEGIN_DUMP "\n====\n(%P|%t|%x)" #define ACE_END_DUMP "====\n" @@ -952,7 +958,9 @@ typedef void (*ACE_SignalHandlerV)(...); // mistakenly passing an HPEN to a routine expecting an HBITMAP. // Note that we only use this if we #if defined (ACE_HAS_STRICT) +#if !defined (STRICT) // may already be defined #define STRICT +#endif /* !STRICT */ #endif /* ACE_HAS_STRICT */ #include /**/ <sys/timeb.h> @@ -983,11 +991,6 @@ typedef void (*ACE_SignalHandlerV)(...); #define ACE_INVALID_SEM_KEY 0 #define ACE_DEFAULT_MUTEX __TEXT ("ACE_MUTEX") -// This flag speeds up the inclusion of Win32 header files. -#if !defined (WIN32_LEAN_AND_MEAN) -#define WIN32_LEAN_AND_MEAN 1 -#endif /* !defined (WIN32_LEAN_AND_MEAN) */ - #define ACE_SEH_TRY __try #define ACE_SEH_EXCEPT(X) __except(X) @@ -1041,17 +1044,8 @@ PAGE_GUARD PAGE_NOACCESS PAGE_NOCACHE */ -// This is necessary since MFC users apparently can't #include -// <windows.h> directly. -#if !defined (__AFX_H__) -#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 @@ -284,12 +284,25 @@ ACE_OS::pipe (ACE_HANDLE fds[]) #endif /* VXWORKS */ } +#if defined (DIGITAL_UNIX) +extern "C" { + extern char *_Pctime_r (const time_t *, char *); + extern struct tm *_Plocaltime_r (const time_t *, struct tm *); + extern char *_Pasctime_r (const struct tm *, char *); + extern int _Prand_r (unsigned int *seedptr); +} +#endif /* DIGITAL_UNIX */ + ACE_INLINE int ACE_OS::rand_r (ACE_RANDR_TYPE seed) { // ACE_TRACE ("ACE_OS::rand_r"); #if defined (ACE_HAS_REENTRANT_FUNCTIONS) && defined (ACE_MT_SAFE) +#if defined (DIGITAL_UNIX) + ACE_OSCALL_RETURN (::_Prand_r (seed), int, -1); +#else ACE_OSCALL_RETURN (::rand_r (seed), int, -1); +#endif /* DIGITAL_UNIX */ #else seed = seed; ACE_OSCALL_RETURN (::rand (), int, -1); @@ -4579,14 +4592,6 @@ ACE_OS::ctime (const time_t *t) #endif // ACE_HAS_BROKEN_CTIME) } -#if defined (DIGITAL_UNIX) -extern "C" { - extern char *_Pctime_r (const time_t *, char *); - extern struct tm *_Plocaltime_r (const time_t *, struct tm *); - extern char *_Pasctime_r (const struct tm *, char *); -} -#endif /* DIGITAL_UNIX */ - ACE_INLINE char * ACE_OS::ctime_r (const time_t *t, char *buf, int buflen) { @@ -5238,7 +5243,7 @@ ACE_OS::mkdir (const char *path, mode_t mode) #if defined (ACE_WIN32) ACE_OSCALL_RETURN (::_mkdir (path), int, -1); #elif defined (VXWORKS) - ACE_OSCALL_RETURN (::_mkdir ((char *) path), int, -1); + ACE_OSCALL_RETURN (::mkdir ((char *) path), int, -1); #else ACE_OSCALL_RETURN (::mkdir (path, mode), int, -1); #endif /* VXWORKS */ diff --git a/ace/Pipe.cpp b/ace/Pipe.cpp index 8101c915453..17654051b00 100644 --- a/ace/Pipe.cpp +++ b/ace/Pipe.cpp @@ -30,10 +30,9 @@ ACE_Pipe::open (void) ACE_SOCK_Stream writer; int result = 0; - // Bind listener to any port - if (acceptor.open (ACE_Addr::sap_any) == -1) - result = -1; - else if (acceptor.get_local_addr (my_addr) == -1) + // Bind listener to any port and then find out what the port was. + if (acceptor.open (ACE_Addr::sap_any) == -1 + || acceptor.get_local_addr (my_addr) == -1) result = -1; else { diff --git a/ace/README b/ace/README index fbcca13ce6f..08f645766a0 100644 --- a/ace/README +++ b/ace/README @@ -120,6 +120,7 @@ ACE_HAS_UCONTEXT_T Platform supports ucontext_t (which is used in the extended ACE_HAS_UNION_WAIT The wait() system call takes a (union wait *) rather than int * ACE_HAS_UNIXWARE_SVR4_SIGNAL_T Has inconsistent SVR4 signal stuff, but not the same as the other platforms ACE_HAS_UNICODE Platform/compiler supports UNICODE +ACE_HAS_USING_KEYWORD Compiler supports the new using keyword for C++ namespaces. 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() diff --git a/ace/SOCK.h b/ace/SOCK.h index fd0ef7789df..bc2e64dc022 100644 --- a/ace/SOCK.h +++ b/ace/SOCK.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY @@ -28,11 +27,6 @@ class ACE_Export ACE_SOCK : public ACE_IPC_SAP // ACE_SOCK abstraction. { public: - int open (int type, - int protocol_family, - int protocol); - // Wrapper around the socket() system call. - int set_option (int level, int option, void *optval, @@ -66,6 +60,11 @@ protected: ACE_SOCK (void); // Default constructor. + int open (int type, + int protocol_family, + int protocol); + // Wrapper around the socket() system call. + ACE_SOCK (int type, int protocol_family, int protocol = 0); // Wrapper around the socket() system call. diff --git a/ace/SOCK_Dgram.h b/ace/SOCK_Dgram.h index 8ce511532bd..402a38c9bce 100644 --- a/ace/SOCK_Dgram.h +++ b/ace/SOCK_Dgram.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // =========================================================================== // // = LIBRARY diff --git a/ace/SPIPE_Acceptor.cpp b/ace/SPIPE_Acceptor.cpp index 6c2d64742b0..2597aa64b4d 100644 --- a/ace/SPIPE_Acceptor.cpp +++ b/ace/SPIPE_Acceptor.cpp @@ -113,7 +113,6 @@ ACE_SPIPE_Acceptor::close (void) return result; } -ACE_INLINE ACE_SPIPE_Acceptor::ACE_SPIPE_Acceptor (const ACE_SPIPE_Addr &local_sap, int reuse_addr, int perms) diff --git a/ace/SV_Semaphore_Complex.h b/ace/SV_Semaphore_Complex.h index 6d61ab30d1b..a0a198f385c 100644 --- a/ace/SV_Semaphore_Complex.h +++ b/ace/SV_Semaphore_Complex.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY @@ -127,8 +126,8 @@ public: int control (int cmd, int value = 0, int n = 0) const; // = Upgrade access control... - ACE_SV_Semaphore_Simple::get_id; - ACE_SV_Semaphore_Simple::remove; + ACE_USING ACE_SV_Semaphore_Simple::get_id; + ACE_USING ACE_SV_Semaphore_Simple::remove; void dump (void) const; // Dump the state of an object. diff --git a/ace/Service_Main.cpp b/ace/Service_Main.cpp index f6d4ea1a4df..b96c06fe7db 100644 --- a/ace/Service_Main.cpp +++ b/ace/Service_Main.cpp @@ -18,16 +18,16 @@ sc_main (int argc, char *argv[]) ACE_ERROR ((LM_ERROR, "%p\n%a", "open", 1)); // Create an adapter to end the event loop. - ACE_Sig_Adapter sa (ACE_Sig_Handler_Ex (ACE_Service_Config::end_reactor_event_loop)); + ACE_Sig_Adapter sa ((ACE_Sig_Handler_Ex) ACE_Service_Config::end_reactor_event_loop); // Register a signal handler. - ACE_Service_Config::reactor ()->register_handler (SIGINT, sa); + ACE_Service_Config::reactor ()->register_handler (SIGINT, &sa); // Run forever, performing the configured services until we are shut // down by a SIGINT/SIGQUIT signal. - while (server_test.reactor_event_loop_done () == 0) - server_test.run_reactor_event_loop (); + while (daemon.reactor_event_loop_done () == 0) + daemon.run_reactor_event_loop (); return 0; } diff --git a/ace/Stream.cpp b/ace/Stream.cpp index 7b120ef43f3..5780ecbc6c4 100644 --- a/ace/Stream.cpp +++ b/ace/Stream.cpp @@ -236,8 +236,9 @@ ACE_Stream<ACE_SYNCH_2>::open (void *a, { ACE_TRACE ("ACE_Stream<ACE_SYNCH_2>::open"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1); - ACE_Task<ACE_SYNCH_2> *h1, *h2; - ACE_Task<ACE_SYNCH_2> *t1, *t2; + + ACE_Task<ACE_SYNCH_2> *h1 = 0, *h2 = 0; + ACE_Task<ACE_SYNCH_2> *t1 = 0, *t2 = 0; if (head == 0) { @@ -255,8 +256,8 @@ ACE_Stream<ACE_SYNCH_2>::open (void *a, } // Make sure *all* the allocation succeeded! - if (h1 == 0 || h2 == 0 || head == 0 - || t1 == 0 || t2 == 0 || tail == 0) + if (head == 0 && (h1 == 0 || h2 == 0) + || tail == 0 && (t1 == 0 || t2 == 0)) { delete h1; delete h2; diff --git a/ace/Synch.h b/ace/Synch.h index cd93af0fe77..030f7996c8b 100644 --- a/ace/Synch.h +++ b/ace/Synch.h @@ -22,7 +22,9 @@ #define ACE_SYNCH_H #include "ace/ACE.h" +#if !(defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM)) #include "ace/SV_Semaphore_Complex.h" +#endif /* !(defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM)) */ // Forward declarations. class ACE_Time_Value; diff --git a/ace/Synch.i b/ace/Synch.i index 461fbbe32b2..03f72d67af2 100644 --- a/ace/Synch.i +++ b/ace/Synch.i @@ -289,8 +289,13 @@ ACE_INLINE int ACE_Thread_Mutex_Guard::release (void) { // ACE_TRACE ("ACE_Thread_Mutex_Guard::release"); - this->owner_ = -1; - return this->lock_.release (); + if (this->owner_ != -1) + { + this->owner_ = -1; + return this->lock_.release (); + } + else + return 0; } // Explicitly release the lock. diff --git a/ace/Synch_T.h b/ace/Synch_T.h index 0f559bd2271..1353bcf7b88 100644 --- a/ace/Synch_T.h +++ b/ace/Synch_T.h @@ -259,8 +259,17 @@ public: int tryacquire (void) { return this->owner_ = this->lock_->tryacquire (); } // Conditionally acquire the lock (i.e., won't block). - int release (void) { this->owner_ = -1; return this->lock_->release (); } - // Explicitly release the lock. + int release (void) + { + if (this->owner_ != -1) + { + this->owner_ = -1; + return this->lock_->release (); + } + else + return 0; + } + // Explicitly release the lock, but only if it is held! void dump (void) const; // Dump the state of an object. diff --git a/ace/TLI_Acceptor.cpp b/ace/TLI_Acceptor.cpp index 4fce1af33d2..12415b3611a 100644 --- a/ace/TLI_Acceptor.cpp +++ b/ace/TLI_Acceptor.cpp @@ -142,7 +142,7 @@ open_new_endpoint (ACE_HANDLE listen_handle, const char dev[], // Close down the acceptor and release resources. -ACE_INLINE int +int ACE_TLI_Request_Queue::close (void) { ACE_TRACE ("ACE_TLI_Request_Queue::close"); @@ -189,7 +189,6 @@ ACE_TLI_Request_Queue::open (ACE_HANDLE f, int sz) return 0; } -ACE_INLINE ACE_TLI_Request_Queue::ACE_TLI_Request_Queue (void) : size_ (0), current_count_ (0), diff --git a/ace/Task.cpp b/ace/Task.cpp index dcdc13a74a0..b61699c8213 100644 --- a/ace/Task.cpp +++ b/ace/Task.cpp @@ -118,7 +118,7 @@ ACE_Task_Base::ACE_Task_Base (ACE_Thread_Manager *thr_man) } // Get the current group id. -ACE_INLINE int +int ACE_Task_Base::grp_id (void) { ACE_TRACE ("ACE_Task_Base::grp_id"); @@ -127,7 +127,7 @@ ACE_Task_Base::grp_id (void) } // Set the current group id. -ACE_INLINE void +void ACE_Task_Base::grp_id (int id) { ACE_TRACE ("ACE_Task_Base::grp_id"); @@ -184,7 +184,7 @@ ACE_Task_Base::activate (long flags, this->thr_mgr_ = ACE_Service_Config::thr_mgr (); this->grp_id_ = this->thr_mgr_->spawn_n (n_threads, - &ACE_Task_Base::svc_run, + ACE_THR_FUNC (&ACE_Task_Base::svc_run), (void *) this, flags, priority, diff --git a/ace/Thread_Manager.cpp b/ace/Thread_Manager.cpp index 388f83f1a9f..1573e94ed26 100644 --- a/ace/Thread_Manager.cpp +++ b/ace/Thread_Manager.cpp @@ -435,13 +435,17 @@ ACE_Thread_Manager::kill_thr (int i, int signum) { ACE_TRACE ("ACE_Thread_Manager::kill_thr"); - int result = ACE_Thread::kill ((ACE_thread_t) this->thr_table_[i].thr_handle_, + int result = ACE_Thread::kill ((ACE_thread_t) this->thr_table_[i].thr_id_, signum); - if (result != 0) + if (result != 0) { + // We need to save this across calls to remove_thr() since that + // call may reset errno. + int error = errno; + this->remove_thr (i); - errno = result; + errno = error; return -1; } else diff --git a/ace/XtReactor.cpp b/ace/XtReactor.cpp index b3ce9a152f5..e51a3552181 100644 --- a/ace/XtReactor.cpp +++ b/ace/XtReactor.cpp @@ -26,7 +26,8 @@ ACE_XtReactor::ACE_XtReactor (XtAppContext context, : ACE_Reactor (size, restart, h), context_ (context), id_len_ (0), - ids_ (0) + ids_ (0), + timeout_ (0) { // When the ACE_Reactor is constructed it creates the notify pipe // and registers it with the attach() method. The XtReactor diff --git a/ace/XtReactor.h b/ace/XtReactor.h index 7ba58b88867..a942757c48f 100644 --- a/ace/XtReactor.h +++ b/ace/XtReactor.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY diff --git a/ace/config-vxworks-ghs-1.8.h b/ace/config-vxworks-ghs-1.8.h index 9204d3f60d1..d8a5dcedbcd 100644 --- a/ace/config-vxworks-ghs-1.8.h +++ b/ace/config-vxworks-ghs-1.8.h @@ -50,5 +50,9 @@ typedef int key_t; #include /**/ <stdarg.h> #include /**/ <vxWorks.h> +#if !defined (ACE_NTRACE) +#define ACE_NTRACE 1 +#endif /* ACE_NTRACE */ +#define ACE_HAS_STRBUF_T #endif /* ACE_CONFIG_H */ diff --git a/ace/config-vxworks5.2-g++.h b/ace/config-vxworks5.2-g++.h index deaeac7d28e..94b6e353479 100644 --- a/ace/config-vxworks5.2-g++.h +++ b/ace/config-vxworks5.2-g++.h @@ -48,6 +48,10 @@ // Defines the page size of the system. #define ACE_PAGE_SIZE 4096 +#if !defined (ACE_NTRACE) +#define ACE_NTRACE 1 +#endif /* ACE_NTRACE */ +#define ACE_HAS_STRBUF_T // vxWorks.h must be included before time.h, and key_t must be // defined early also: these are here diff --git a/ace/config-win32-msvc2.0.h b/ace/config-win32-msvc2.0.h index 8bfd4740aa0..39e20521759 100644 --- a/ace/config-win32-msvc2.0.h +++ b/ace/config-win32-msvc2.0.h @@ -7,8 +7,91 @@ #if !defined (ACE_CONFIG_H) #define ACE_CONFIG_H +#if !defined (ACE_CONFIG_H) +#define ACE_CONFIG_H + +#if defined (_MSC_VER) + // "C4355: 'this' : used in base member initializer list" + #pragma warning(disable:4355) // disable C4514 warning +// #pragma warning(default:4355) // use this to reenable, if desired + + #pragma warning(disable:4201) // winnt.h uses nameless structs +#endif /* _MSC_VER */ +// While digging the MSVC 4.0 include files, I found how to disable MSVC +// warnings: +// --Amos Shapira + +// Comment this out for now since it will break existing application +// code. +#define ACE_HAS_STRICT + +// <windows.h> and MFC's <afxwin.h> are mutually +// incompatible. <windows.h> is brain-dead about MFC; it doesn't check +// to see whether MFC stuff is anticipated or already in progress +// before doing its thing. ACE needs (practically always) <winsock.h>, +// and winsock in turn needs support either from windows.h or from +// afxwin.h. One or the other, not both. +// +// The MSVC++ V4.0 environment defines preprocessor macros that +// indicate the programmer has chosen something from the +// Build-->Settings-->General-->MFC combo-box. <afxwin.h> defines a +// macro itself to protect against double inclusion. We'll take +// advantage of all this to select the proper support for winsock. - +// trl 26-July-1996 + +// This is necessary since MFC users apparently can't #include +// <windows.h> directly. +#if ( defined (_AFXDLL) || defined (_WINDLL)) + #include /**/ <afxwin.h> // He is doing MFC + // Windows.h will be included via afxwin.h->afx.h->afx_ver_.h->afxv_w32.h + // #define _INC_WINDOWS // Prevent winsock.h from including windows.h +#endif + +#if !defined (_INC_WINDOWS) // Already include windows.h ? + // Must define strict before including windows.h ! + #if (defined ACE_HAS_STRICT) + #define STRICT 1 + #endif + + #ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN + #endif + + #ifdef _UNICODE + #ifndef UNICODE + #define UNICODE // UNICODE is used by Windows headers + #endif + #endif + + #ifdef UNICODE + #ifndef _UNICODE + #define _UNICODE // _UNICODE is used by C-runtime/MFC headers + #endif + #endif +#endif + +// Define the following macro if you're compiling with WinSock 2.0. +// #define ACE_HAS_WINSOCK2 + // Needed for timeval. -#include /**/ <winsock.h> +#if defined (ACE_HAS_WINSOCK2) + #ifndef _WINSOCK2API_ + #include /**/ <winsock2.h> // will also include windows.h, if not present + #endif + + #define ACE_WSOCK_VERSION 2, 0 +#else + #ifndef _WINSOCKAPI_ + #include /**/ <winsock.h> // will also include windows.h, if not present + #endif + + // Version 1.1 of WinSock + #define ACE_WSOCK_VERSION 1, 1 +#endif /* ACE_HAS_WINSOCK2 */ + +#if defined (_MSC_VER) + #pragma warning(default: 4201) // winnt.h uses nameless structs +#endif /* _MSC_VER */ #define ACE_HAS_UNICODE @@ -131,4 +214,7 @@ inline void *operator new (unsigned int, void *p) { return p; } #define ACE_NEEDS_WRITEV #define ACE_NEEDS_READV +// Compiler/Platform supports the "using" keyword. +// #define ACE_HAS_USING_KEYWORD + #endif /* ACE_CONFIG_H */ diff --git a/ace/config-win32-msvc4.0.h b/ace/config-win32-msvc4.0.h index bc0dcfa9f98..050a3776dbe 100644 --- a/ace/config-win32-msvc4.0.h +++ b/ace/config-win32-msvc4.0.h @@ -7,14 +7,23 @@ #if !defined (ACE_CONFIG_H) #define ACE_CONFIG_H +#if !defined (ACE_CONFIG_H) +#define ACE_CONFIG_H + #if defined (_MSC_VER) // "C4355: 'this' : used in base member initializer list" #pragma warning(disable:4355) // disable C4514 warning -// #pragma warning(default:4355) // use this to reenable, if desired +// #pragma warning(default:4355) // use this to reenable, if desired + +#pragma warning(disable:4201) // winnt.h uses nameless structs #endif /* _MSC_VER */ -// While digging the MSVC 4.0 include files, I found how to disable MSVC -// warnings: -// --Amos Shapira + +// While digging the MSVC 4.0 include files, I found how to disable +// MSVC warnings: --Amos Shapira + +// Comment this out for now since it will break existing application +// code. +// #define ACE_HAS_STRICT // <windows.h> and MFC's <afxwin.h> are mutually // incompatible. <windows.h> is brain-dead about MFC; it doesn't check @@ -30,35 +39,60 @@ // advantage of all this to select the proper support for winsock. - // trl 26-July-1996 -#ifdef _AFXDLL // May be defined by MSVC++ IDE -#include /**/ <afxwin.h> // He is doing MFC -#define _INC_WINDOWS // Prevent winsock.h from including windows.h -#endif -#ifdef _WINDLL // May be defined by MSVC++ IDE +// This is necessary since MFC users apparently can't #include +// <windows.h> directly. +#if defined (_AFXDLL) || defined (_WINDLL) #include /**/ <afxwin.h> // He is doing MFC -#define _INC_WINDOWS // Prevent winsock.h from including windows.h + // Windows.h will be included via afxwin.h->afx.h->afx_ver_.h->afxv_w32.h + // #define _INC_WINDOWS // Prevent winsock.h from including windows.h #endif -#ifndef __AFX_H__ // set in afxwin.h -#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. +#if !defined (_INC_WINDOWS) // Already include windows.h ? + // Must define strict before including windows.h ! +#if defined (ACE_HAS_STRICT) +#define STRICT 1 +#endif /* ACE_HAS_STRICT */ + +#if !defined (WIN32_LEAN_AND_MEAN) +#define WIN32_LEAN_AND_MEAN +#endif /* WIN32_LEAN_AND_MEAN */ + +#if defined (_UNICODE) +#if !defined (UNICODE) +#define UNICODE // UNICODE is used by Windows headers +#endif /* UNICODE */ +#endif /* _UNICODE */ + +#if defined (UNICODE) +#if !defined (_UNICODE) +#define _UNICODE // _UNICODE is used by C-runtime/MFC headers +#endif /* _UNICODE */ +#endif /* UNICODE */ +#endif /* !defined (_INC_INWDOWS) */ + +// Define the following macro 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. #if defined (ACE_HAS_WINSOCK2) -#include /**/ <winsock2.h> -#include "ace/ws2tcpip.h" +#if !defined (_WINSOCK2API_) +#include /**/ <winsock2.h> // will also include windows.h, if not present +#endif /* _WINSOCK2API */ + +#define ACE_WSOCK_VERSION 2, 0 #else -#include /**/ <winsock.h> +#if !defined (_WINSOCKAPI_) +#include /**/ <winsock.h> // will also include windows.h, if not present +#endif /* _WINSOCKAPI */ + +// Version 1.1 of WinSock +#define ACE_WSOCK_VERSION 1, 1 #endif /* ACE_HAS_WINSOCK2 */ +#if defined (_MSC_VER) +#pragma warning(default: 4201) // winnt.h uses nameless structs +#endif /* _MSC_VER */ + #define ACE_HAS_UNICODE #define ACE_HAS_STL @@ -180,7 +214,7 @@ #define ACE_NEEDS_WRITEV #define ACE_NEEDS_READV -// Comment this out for now since it will break existing application -// code. -#define ACE_HAS_STRICT +// Compiler/Platform supports the "using" keyword. +#define ACE_HAS_USING_KEYWORD + #endif /* ACE_CONFIG_H */ diff --git a/examples/Misc/test_XtReactor1.cpp b/examples/Misc/test_XtReactor1.cpp index 8669dfb0653..723726bb5b0 100644 --- a/examples/Misc/test_XtReactor1.cpp +++ b/examples/Misc/test_XtReactor1.cpp @@ -8,6 +8,7 @@ #include "ace/Message_Block.h" #if defined (ACE_HAS_XT) +#define String XtString #include <Xm/PushB.h> class Stdout : public ACE_Event_Handler diff --git a/examples/Misc/test_XtReactor2.cpp b/examples/Misc/test_XtReactor2.cpp index 679ea81b758..b43f1eca4f2 100644 --- a/examples/Misc/test_XtReactor2.cpp +++ b/examples/Misc/test_XtReactor2.cpp @@ -8,6 +8,7 @@ #include "ace/Message_Block.h" #if defined (ACE_HAS_XT) +#define String XtString #include <Xm/PushB.h> class Stdin : public ACE_Event_Handler @@ -44,8 +45,8 @@ int main (int argc, char**argv) XtManageChild (button); XtAddCallback (button, XmNactivateCallback, ActivateCB, NULL); - // A reactor beastie - XtReactor reactor (XtWidgetToApplicationContext (top_level)); + // A reactor beastie. + ACE_XtReactor reactor (XtWidgetToApplicationContext (top_level)); // Print a message when data is recv'd on stdin... ACE_Event_Handler * stdin_ = new Stdin; diff --git a/examples/Service_Configurator/IPC-tests/server/server_test.cpp b/examples/Service_Configurator/IPC-tests/server/server_test.cpp index 451f178e256..8e375021959 100644 --- a/examples/Service_Configurator/IPC-tests/server/server_test.cpp +++ b/examples/Service_Configurator/IPC-tests/server/server_test.cpp @@ -13,10 +13,10 @@ main (int argc, char *argv[]) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "server_test.open"), -1); // Create an adapter to end the event loop. - ACE_Sig_Adapter sa (ACE_Sig_Handler_Ex (ACE_Service_Config::end_reactor_event_loop)); + ACE_Sig_Adapter sa ((ACE_Sig_Handler_Ex) ACE_Service_Config::end_reactor_event_loop); // Register a signal handler. - ACE_Service_Config::reactor ()->register_handler (SIGINT, sa); + ACE_Service_Config::reactor ()->register_handler (SIGINT, &sa); // Run forever, performing the configured services until we are shut // down by a SIGINT/SIGQUIT signal. diff --git a/examples/Threads/test_task_three.cpp b/examples/Threads/test_task_three.cpp index 78e9a006321..aedea6fc158 100644 --- a/examples/Threads/test_task_three.cpp +++ b/examples/Threads/test_task_three.cpp @@ -103,7 +103,7 @@ Test_Task::svc (void) for (int index = 0; index < NUM_INVOCATIONS; index++) { - ACE_OS::thr_extern "C" yield (); + ACE_OS::thr_yield (); if (r_->notify (this, ACE_Event_Handler::READ_MASK)) { @@ -181,7 +181,7 @@ main (int argc, char **argv) } // Register a signal handler. - ACE_Sig_Action sa (ACE_Sig_Handler_Ex (handler), SIGINT); + ACE_Sig_Action sa (ACE_SignalHandler (handler), SIGINT); ACE_Reactor *reactor1 = ACE_Service_Config::reactor (); ACE_Reactor *reactor2 = new ACE_Reactor (); diff --git a/examples/Threads/test_thread_manager.cpp b/examples/Threads/test_thread_manager.cpp index a09db55dd51..73029d70d88 100644 --- a/examples/Threads/test_thread_manager.cpp +++ b/examples/Threads/test_thread_manager.cpp @@ -54,7 +54,7 @@ main (int argc, char *argv[]) daemon.open (argv[0]); // Register a signal handler. - ACE_Sig_Action sa (ACE_Sig_Handler_Ex (handler), SIGINT); + ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT); int n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : DEFAULT_THREADS; int n_iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : DEFAULT_ITERATIONS; diff --git a/tests/CPP_Test.cpp b/tests/CPP_Test.cpp index f07da15e976..38855189b84 100644 --- a/tests/CPP_Test.cpp +++ b/tests/CPP_Test.cpp @@ -23,7 +23,7 @@ #include "ace/OS.h" #include "ace/Thread.h" -#include "ace/Thread_Manager.h" +#include "ace/Service_Config.h" #include "ace/SOCK_Connector.h" #include "ace/SOCK_Acceptor.h" #include "ace/SOCK_Stream.h" @@ -31,108 +31,89 @@ #include "ace/Handle_Set.h" #include "test_config.h" -static char *host = ACE_DEFAULT_SERVER_HOST; -static u_short port = ACE_DEFAULT_SERVER_PORT; -static int timeout = ACE_DEFAULT_TIMEOUT; -// Global thread manager. -static ACE_Thread_Manager thr_mgr; - static void * -client (void *) +client (void *arg) { -#if defined (ACE_WIN32) +#if (defined (ACE_WIN32) || defined (VXWORKS)) && defined (ACE_HAS_THREADS) // Insert thread into thr_mgr - ACE_Thread_Control thread_control (&thr_mgr); + ACE_Thread_Control thread_control (ACE_Service_Config::thr_mgr ()); ACE_NEW_THREAD; -#endif - - char buf[BUFSIZ]; +#endif /* (defined (ACE_WIN32) || defined (VXWORKS)) && defined (ACE_HAS_THREADS) */ + ACE_INET_Addr *remote_addr = (ACE_INET_Addr *) arg; ACE_SOCK_Stream cli_stream; - ACE_INET_Addr remote_addr (port, host); ACE_SOCK_Connector con; - ACE_DEBUG ((LM_DEBUG, "starting non-blocking connect\n")); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) starting non-blocking connect\n")); // Initiate timed, non-blocking connection with server. - ACE_OS::sleep (3); // Attempt a non-blocking connect to the server, reusing the local // addr if necessary. - if (con.connect (cli_stream, remote_addr, + if (con.connect (cli_stream, *remote_addr, (ACE_Time_Value *) &ACE_Time_Value::zero) == -1) { if (errno != EWOULDBLOCK) - ACE_ERROR ((LM_ERROR, "%p\n", "connection failed")); + ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "connection failed")); - ACE_DEBUG ((LM_DEBUG, "starting timed connect\n")); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) starting timed connect\n")); // Check if non-blocking connection is in progress, - // and wait up to timeout seconds for it to complete. - ACE_Time_Value tv (timeout); + // and wait up to ACE_DEFAULT_TIMEOUT seconds for it to complete. + ACE_Time_Value tv (ACE_DEFAULT_TIMEOUT); - if (con.complete (cli_stream, &remote_addr, &tv) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "connection failed")); + if (con.complete (cli_stream, remote_addr, &tv) == -1) + ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "connection failed")); else - ACE_DEBUG ((LM_DEBUG, "connected to %s\n", remote_addr.get_host_name ())); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) connected to %s\n", + remote_addr->get_host_name ())); } if (cli_stream.disable (ACE_NONBLOCK) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "disable")); + ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "disable")); // Send data to server (correctly handles "incomplete writes"). for (char c = 'a'; c <= 'z'; c++) if (cli_stream.send_n (&c, 1) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "send_n")); + ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "send_n")); // Explicitly close the writer-side of the connection. if (cli_stream.close_writer () == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "close_writer")); + ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "close_writer")); - // Wait for handshake with server. + char buf[1]; + + // Wait for handshake with server. if (cli_stream.recv_n (buf, 1) != 1) - ACE_ERROR ((LM_ERROR, "%p\n", "recv_n")); + ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "recv_n")); - // Close the connection completely. + // Close the connection completely. if (cli_stream.close () == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "close")); + ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "close")); -#if !defined (ACE_WIN32) - ACE_OS::exit (0); -#endif return 0; } static void * -server (void *) +server (void *arg) { -#if defined (ACE_WIN32) +#if (defined (ACE_WIN32) || defined (VXWORKS)) && defined (ACE_HAS_THREADS) // Insert thread into thr_mgr - ACE_Thread_Control thread_control (&thr_mgr); + ACE_Thread_Control thread_control (ACE_Service_Config::thr_mgr ()); ACE_NEW_THREAD; -#endif - ACE_SOCK_Acceptor peer_acceptor; +#endif /* (defined (ACE_WIN32) || defined (VXWORKS)) && defined (ACE_HAS_THREADS) */ - // Create a server address. - ACE_INET_Addr server_addr (port); - - // Create a server, reuse the address. - if (peer_acceptor.open (server_addr, 1) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "open")); - else if (peer_acceptor.enable (ACE_NONBLOCK) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "enable")); - else if (peer_acceptor.get_local_addr (server_addr) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "get_local_addr")); + ACE_SOCK_Acceptor *peer_acceptor = (ACE_SOCK_Acceptor *) arg; - ACE_DEBUG ((LM_DEBUG, "starting server at port %d\n", - server_addr.get_port_number ())); + if (peer_acceptor->enable (ACE_NONBLOCK) == -1) + ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "enable")); // Keep these objects out here to prevent excessive constructor // calls... ACE_SOCK_Stream new_stream; ACE_INET_Addr cli_addr; ACE_Handle_Set handle_set; - ACE_Time_Value tv (timeout); + ACE_Time_Value tv (ACE_DEFAULT_TIMEOUT); // Performs the iterative server activities. for (;;) @@ -141,31 +122,30 @@ server (void *) char t = 'a'; handle_set.reset (); - handle_set.set_bit (peer_acceptor.get_handle ()); + handle_set.set_bit (peer_acceptor->get_handle ()); - int result = ACE_OS::select (int (peer_acceptor.get_handle ()) + 1, + int result = ACE_OS::select (int (peer_acceptor->get_handle ()) + 1, handle_set, 0, 0, &tv); - if (result == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "select")); + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", "select"), 0); else if (result == 0) { - ACE_DEBUG ((LM_DEBUG, "select timed out\n")); - continue; + ACE_DEBUG ((LM_DEBUG, "(%P|%t) select timed out, shutting down\n")); + return 0; } // Create a new ACE_SOCK_Stream endpoint (note automatic restart // if errno == EINTR). - while ((result = peer_acceptor.accept (new_stream, &cli_addr)) != -1) + while ((result = peer_acceptor->accept (new_stream, &cli_addr)) != -1) { - ACE_DEBUG ((LM_DEBUG, "client %s connected from %d\n", + ACE_DEBUG ((LM_DEBUG, "(%P|%t) client %s connected from %d\n", cli_addr.get_host_name (), cli_addr.get_port_number ())); // Enable non-blocking I/O. if (new_stream.enable (ACE_NONBLOCK) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "enable")); + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", "enable"), 0); handle_set.reset (); handle_set.set_bit (new_stream.get_handle ()); @@ -177,10 +157,7 @@ server (void *) if (ACE_OS::select (int (new_stream.get_handle ()) + 1, handle_set, 0, 0, 0) == -1) - { - ACE_ERROR ((LM_ERROR, "%p\n", "select")); - ACE_OS::exit (1); - } + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", "select"), 0); while ((r_bytes = new_stream.recv_n (buf, 1)) > 0) { @@ -190,32 +167,34 @@ server (void *) if (r_bytes == 0) { - ACE_DEBUG ((LM_DEBUG, "reached end of input, connection closed by client\n")); + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) reached end of input, connection closed by client\n")); + + // Handshake back with client. + if (new_stream.send_n ("", 1) != 1) + ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "send_n")); + + // Close endpoint. + if (new_stream.close () == -1) + ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "close")); return 0; } else if (r_bytes == -1) { if (errno == EWOULDBLOCK) - ACE_DEBUG ((LM_DEBUG, "no input available, going back to reading\n")); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) no input available, going back to reading\n")); else - ACE_ERROR ((LM_ERROR, "%p\n", "recv_n")); + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", "recv_n"), 0); } - - if (new_stream.send_n ("", 1) != 1) - ACE_ERROR ((LM_ERROR, "%p\n", "send_n")); } - - // Close new endpoint (listening endpoint stays open). - if (new_stream.close () == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "close")); } if (result == -1) { if (errno == EWOULDBLOCK) - ACE_DEBUG ((LM_DEBUG, "no connections available, going back to accepting\n")); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) no connections available, going back to accepting\n")); else - ACE_ERROR ((LM_ERROR, "%p\n", "accept")); + ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "accept")); } } return 0; @@ -224,31 +203,49 @@ server (void *) static void spawn (void) { -#if !defined (ACE_WIN32) && !defined (VXWORKS) - switch (ACE_OS::fork ()) + // Acceptor + ACE_SOCK_Acceptor peer_acceptor; + + // Create a server address. + ACE_INET_Addr server_addr; + + // Bind listener to any port and then find out what the port was. + if (peer_acceptor.open (ACE_Addr::sap_any) == -1 + || peer_acceptor.get_local_addr (server_addr) == -1) + ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n", "open")); + else { - case -1: - ACE_ERROR ((LM_ERROR, "%p\n%a", "fork failed")); - exit (-1); - case 0: - client (0); - default: - server (0); - } + ACE_DEBUG ((LM_DEBUG, "(%P|%t) starting server at port %d\n", + server_addr.get_port_number ())); + +#if !defined (ACE_WIN32) && !defined (VXWORKS) + switch (ACE_OS::fork ()) + { + case -1: + ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n%a", "fork failed")); + exit (-1); + case 0: + ACE_LOG_MSG->sync ("child"); + client (&server_addr); + default: + server ((void *) &peer_acceptor); + ACE_OS::wait (); + } #elif defined (ACE_HAS_THREADS) - if (thr_mgr.spawn (ACE_THR_FUNC (client), - (void *) 0, - THR_NEW_LWP | THR_DETACHED) == -1) - ACE_ERROR ((LM_ERROR, "%p\n%a", "thread create failed")); - - if (thr_mgr.spawn (ACE_THR_FUNC (server), - (void *) 0, - THR_NEW_LWP | THR_DETACHED) == -1) - ACE_ERROR ((LM_ERROR, "%p\n%a", "thread create failed")); - thr_mgr.wait (); + if (ACE_Service_Config::thr_mgr ()->spawn + (ACE_THR_FUNC (client), (void *) &server_addr, THR_NEW_LWP | THR_DETACHED) == -1) + ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n%a", "thread create failed")); + + if (ACE_Service_Config::thr_mgr ()->spawn + (ACE_THR_FUNC (server), (void *) &peer_acceptor, THR_NEW_LWP | THR_DETACHED) == -1) + ACE_ERROR ((LM_ERROR, "(%P|%t) %p\n%a", "thread create failed")); + + // Wait for the threads to exit. + ACE_Service_Config::thr_mgr ()->wait (); #else - ACE_ERROR ((LM_ERROR, "only one thread may be run in a process on this platform\n%a", 1)); + ACE_ERROR ((LM_ERROR, "(%P|%t) only one thread may be run in a process on this platform\n%a", 1)); #endif /* ACE_HAS_THREADS */ + } } int diff --git a/tests/Mutex_Test.cpp b/tests/Mutex_Test.cpp index a149243aa75..c6ccdf466ce 100644 --- a/tests/Mutex_Test.cpp +++ b/tests/Mutex_Test.cpp @@ -27,15 +27,18 @@ static void * test (void *args) { ACE_Process_Mutex *pm = (ACE_Process_Mutex *) args; +#if (defined (ACE_WIN32) || defined (VXWORKS)) && defined (ACE_HAS_THREADS) ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); + ACE_NEW_THREAD; +#endif /* (defined (ACE_WIN32) || defined (VXWORKS)) && defined (ACE_HAS_THREADS) */ ACE_OS::srand (ACE_OS::time (0)); for (int i = 0; i < ACE_MAX_ITERATIONS; i++) { - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = trying to acquire\n")); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = trying to acquire on iteration %d\n", i)); ACE_ASSERT (pm->acquire () == 0); - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = acquired\n")); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = acquired on iteration %d\n", i)); // Sleep for a random amount of time between 0 and 5 seconds. // Note that it's ok to use rand() here because we are running @@ -43,7 +46,7 @@ test (void *args) ACE_OS::sleep (ACE_OS::rand () % 5); ACE_ASSERT (pm->release () == 0); - ACE_DEBUG ((LM_DEBUG, "(%P|%t) = released\n")); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) = released on iteration %d\n", i)); } return 0; @@ -74,7 +77,6 @@ spawn (void) // Allow the client to exit, then remove the Process_Mutex. ACE_OS::wait (); - pm.remove (); break; } diff --git a/tests/Reactors_Test.cpp b/tests/Reactors_Test.cpp index 07a38573a76..be182edb40f 100644 --- a/tests/Reactors_Test.cpp +++ b/tests/Reactors_Test.cpp @@ -158,10 +158,10 @@ worker (void *args) switch (reactor->handle_events (timeout)) { case -1: - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "reactor"), 0); + ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "reactor"), 0); /* NOTREACHED */ case 0: - ACE_ERROR_RETURN ((LM_ERROR, "timeout\n"), 0); + ACE_ERROR_RETURN ((LM_ERROR, "(%t) timeout\n"), 0); /* NOTREACHED */ } } @@ -210,4 +210,3 @@ main (int, char *argv[]) ACE_END_TEST; return 0; } - diff --git a/tests/Win32tokens.conf b/tests/Win32tokens.conf index ecf1a7604d7..61906bc76a4 100644 --- a/tests/Win32tokens.conf +++ b/tests/Win32tokens.conf @@ -1,6 +1,4 @@ # NT version # - dynamic Logging_Strategy Service_Object * netsvcs.dll:_make_ACE_Logging_Strategy() "-s c:\temp\log\Tokens_Test_Server.log -f OSTREAM" dynamic Token_Service Service_Object * netsvcs.dll:_make_ACE_Token_Acceptor() "-p 23456" - diff --git a/tests/test_config.h b/tests/test_config.h index 04d1c339d5d..c6603f2e915 100644 --- a/tests/test_config.h +++ b/tests/test_config.h @@ -6,7 +6,8 @@ // test_config.h // // = AUTHOR -// Prashant Jain <pjain@cs.wustl.edu> and Tim Harrison <harrison@cs.wustl.edu> +// Prashant Jain <pjain@cs.wustl.edu>, Tim Harrison +// <harrison@cs.wustl.edu>, and David Levine <levine@cs.wustl.edu> // // ============================================================================ @@ -33,11 +34,11 @@ ACE_LOG_MSG->open (program, ACE_Log_Msg::OSTREAM); \ if (ace_file_stream.set_output (program) != 0) \ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "set_output failed"), -1); \ - ACE_DEBUG ((LM_DEBUG, "starting %s test at %T\n", program)); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) starting %s test at %T\n", program)); #define ACE_END_TEST \ - ACE_DEBUG ((LM_DEBUG, "Ending %s test at %T\n", program)); \ - ace_file_stream.flush (); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) Ending %s test at %T\n", program)); \ + ace_file_stream.close (); #define ACE_NEW_THREAD \ do {\ @@ -60,7 +61,7 @@ public: ~ACE_Test_Output (void); int set_output (const char *filename); ofstream *output_file (void); - void flush (void); + void close (void); private: ofstream *output_file_; @@ -101,8 +102,9 @@ ACE_Test_Output::output_file (void) } void -ACE_Test_Output::flush (void) +ACE_Test_Output::close (void) { this->output_file_->flush (); + this->output_file_->close (); } #endif /* ACE_TEST_CONFIG_H */ |