summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog-96b109
-rw-r--r--README1
-rw-r--r--ace/ACE.cpp6
-rw-r--r--ace/INET_Addr.cpp1
-rw-r--r--ace/Log_Msg.cpp23
-rw-r--r--ace/Map_Manager.cpp5
-rw-r--r--ace/OS.cpp16
-rw-r--r--ace/OS.h36
-rw-r--r--ace/OS.i20
-rw-r--r--ace/Pipe.cpp7
-rw-r--r--ace/README2
-rw-r--r--ace/Reactor.cpp9
-rw-r--r--ace/Reactor.h1
-rw-r--r--ace/Service_Main.cpp30
-rw-r--r--ace/Signal.cpp28
-rw-r--r--ace/Signal.h20
-rw-r--r--ace/Thread.h2
-rw-r--r--ace/Thread.i2
-rw-r--r--ace/Thread_Manager.i2
-rw-r--r--ace/Time_Request_Reply.cpp4
-rw-r--r--ace/Time_Request_Reply.h4
-rw-r--r--ace/UPIPE_Stream.cpp2
-rw-r--r--ace/config-mvs.h6
-rw-r--r--examples/Logger/simple-server/server_loggerd.cpp8
-rw-r--r--examples/Mem_Map/IO-tests/test_io.cpp35
-rw-r--r--examples/Reactor/Misc/test_signals_2.cpp4
-rw-r--r--examples/Reactor/Ntalker/ntalker.cpp5
-rw-r--r--examples/Reactor/ReactorEx/test_reactorEx.cpp1
-rw-r--r--examples/Reactor/WFMO_Reactor/test_reactorEx.cpp1
-rw-r--r--examples/Service_Configurator/IPC-tests/server/server_test.cpp27
-rw-r--r--examples/Shared_Malloc/test_malloc.cpp7
-rw-r--r--examples/System_V_IPC/SV_Message_Queues/MQ_Server.cpp13
-rw-r--r--examples/System_V_IPC/SV_Message_Queues/TMQ_Server.cpp11
-rw-r--r--examples/System_V_IPC/SV_Semaphores/Semaphore_Server.cpp13
-rw-r--r--examples/Threads/test_process_mutex.cpp15
-rw-r--r--examples/Threads/test_process_semaphore.cpp8
-rw-r--r--examples/Threads/test_task_three.cpp11
-rw-r--r--examples/Threads/test_thread_manager.cpp9
-rw-r--r--examples/Threads/test_thread_specific.cpp10
39 files changed, 332 insertions, 182 deletions
diff --git a/ChangeLog-96b b/ChangeLog-96b
index e3cb6cdf39a..fbc3191defa 100644
--- a/ChangeLog-96b
+++ b/ChangeLog-96b
@@ -1,10 +1,54 @@
-Tue Nov 26 21:35:53 1996 David L. Levine <levine@cs.wustl.edu>
+Tue Nov 26 18:00:25 1996 Douglas C. Schmidt <schmidt@lambada.cs.wustl.edu>
- * ace/OS.cpp: check for 0 thr_id before dereferencing with
- STHREADS in ACE_OS::thr_create()
+ * 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
+ allow the ACE library to build...
- * Log_Msg.cpp: fake out TSS on VxWorks in Log_Msg::instance()
- by using a spare field in the task control block
+ * man: Updated all of the manual pages and HTML files.
+
+ * ace/Signal.cpp: Updated the code so that we don't try to
+ register a static C++ dispatch method if ACE_HAS_SIG_C_FUNC is
+ defined. This fixes problems with the MVS C++ compiler...
+ Thanks to Chuck Gehr for this suggestion.
+
+ * ace/OS.h: Added extern "C" { } wrappers around the signal
+ handling mechanisms if ACE_HAS_SIG_C_FUNC is defined. This
+ fixes problems with the MVS C++ compiler... Thanks to Chuck
+ Gehr for this suggestion.
+
+ * ace/Reactor.cpp (open): Moved the initialization of the
+ ACE_Timer_Queue field to *before* the handler_rep_.open() call.
+ We do this first in case the handler_rep_ call fails (which it
+ sometimes does on Win32 when we restart applications quickly due
+ to the use of sockets as a notification mechanism). At least
+ this way the timer_queue_ isn't 0, so we can still use the
+ Reactor as a timer... Thanks to Tilo Christ for motivating
+ me to fix this.
+
+ * ace/OS.i: Apparently, DIGITAL_UNIX gethostbyname() returns
+ thread-specific storage, so we can use this for
+ gethostbyname_r().
+
+ * ace/OS.i: Need to add:
+
+ #else
+
+ after line 3268: return (size_t) ACE_OS::sysconf (_SC_THREAD_STACK_MIN);
+
+ otherwise we get a compile error:
+
+ line 3296.1: CBC1331(W) Return value of type "unsigned int" is expected
+
+ This is because no code ends up getting generated. Thanks to Chuck
+ Gehr for this fix.
+
+ * ace/OS.i (ACE_PTHREAD_CLEANUP_PUSH): Removed an extraneous set
+ of parens. Thanks to Chuck Gehr for this fix.
+
+ * ace/OS.cpp (thr_create): Oops, needed to add a check if thr_id
+ == 0 before assigning *thr_handle = *thr_id! Thanks to Prashant
+ for finding this.
Tue Nov 26 21:06:13 1996 Irfan Pyarali <irfan@flamenco.cs.wustl.edu>
@@ -26,7 +70,8 @@ Tue Nov 26 11:27:33 1996 David L. Levine <levine@cs.wustl.edu>
added VXWORKS support for these tests by spawning a new thread
instead of forking a new process (the same as on Win32)
-Tue Nov 26 00:36:16 1996 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
+ * netsvcs/clients/Naming/Client/Client_Test.cpp (open): Added a
+ return 0 for success.
* ace/Singleton.h: Modified the use of the ACE_NEW_RETURN macro so
we not only check if new has failed, but also check that the
@@ -48,6 +93,57 @@ Tue Nov 26 00:36:16 1996 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
ACE_Thread_Mutex. This should fix lots of nasty run-time bugs
seen with recent versions of the ACE 0.33 beta...
+Tue Nov 26 21:06:13 1996 Irfan Pyarali <irfan@flamenco.cs.wustl.edu>
+
+ * ace/Pipe.cpp (open): This change relates to Win32 code only.
+ Removed the reuse_addr flag to acceptor.open() so that we don't
+ try to reuse the acceptor socket immediately. Apparently, this
+ causes no end of trouble on Win32 as the following connect()
+ call fails (randomly). Now it should be possible to create
+ multiple ACE_Pipes in one process and hence create multiple
+ Reactors also without any problems.
+
+Tue Nov 26 14:40:00 1996 David L. Levine <levine@cs.wustl.edu>
+
+ * Log_Msg.cpp: fake out TSS on VxWorks in Log_Msg::instance()
+ by using a spare field in the task control block
+
+ * tests/{CPP_Test,Mutex_Test,Shared_Memory_MM_Test,SPIPE_Test}.cpp:
+ added VXWORKS support for these tests by spawning a new
+ thread instead of forking a new process (the same as on
+ Win32)
+
+ * OS.h: VxWorks can't handle the ACE_THR_FUNC typedef if
+ it's in the extern "C" block, so I moved it back out.
+ Also, the horrible GreenHills hack is no longer required.
+
+ * OS.i: there's an ACE_OS_CALL_RETURN before a ::strncpy() call,
+ I changed it to ACE_OS_CALL.
+
+ * OS.i: Added call to VxWorks ::mkdir()
+
+ * Pipe.cpp: VxWorks doesn't know about TCP_NODELAY.
+
+ * INET_Addr.cpp: get_host_name() is missing a return
+ statement, on VxWorks only
+
+ * Thread_Manager.i: in ACE_Thread_Control::thr_mgr(), there
+ were two consecutive return statements, removed the first
+ one.
+
+ * Time_Request_Reply.{h,cpp}: GreenHills warns that "type
+ qualifiers are meaningless" for declaration of const
+ ACE_UINT32 time(), so I removed them.
+
+ * UPIPE_Stream.cpp, line 95: warning: integer conversion
+ resulted in a change of sign, so we cast n to int.
+
+ * Map_Manager.cpp: in ACE_Map_Manager::resize_i(), variable
+ foo is unnecessary, so we omitted it.
+
+ * tests/CPP_Test.cpp (and a few others) have references to
+ argv[0]:
+
Tue Nov 26 03:15:22 1996 Irfan Pyarali <irfan@flamenco.cs.wustl.edu>
* tests: Added Map_Manager_Test and Message_Queue_Test to
@@ -3992,3 +4088,4 @@ Mon Jul 1 02:15:34 1996 Tim H. Harrison (harrison@lambada.cs.wustl.edu)
all reuse the calculations required by the Timer_Queue without
duplicating code.
+
diff --git a/README b/README
index 753d567a2ed..c936dc45de8 100644
--- a/README
+++ b/README
@@ -662,6 +662,7 @@ Fred LaBar <flabar@fallschurch.esys.com>
Hanan Herzog <hanan@wallenda.stanford.edu>
Eric Parker <eparker@credence.com>
James Michael Dwyer <jdwyer@knox.edu>
+Arun Katkere <katkere@praja.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 73f9ac76c8e..f3f88f79ef2 100644
--- a/ace/ACE.cpp
+++ b/ace/ACE.cpp
@@ -135,7 +135,7 @@ ACE::ldfind (const char *filename,
}
if (ACE_OS::strcmp (searchfilename
- + ACE_OS::strlen(searchfilename) - ACE_OS::strlen (ACE_DLL_SUFFIX),
+ + ACE_OS::strlen (searchfilename) - ACE_OS::strlen (ACE_DLL_SUFFIX),
ACE_DLL_SUFFIX))
ACE_ERROR ((LM_NOTICE,
"CAUTION: improper name for a shared library on this patform: %s\n",
@@ -587,7 +587,9 @@ ACE::bind_port (ACE_HANDLE handle)
{
ACE_TRACE ("ACE::bind_port");
sockaddr_in sin;
- const int MAX_SHORT = 65535;
+ // This should be a constant, so I hope they never change the number
+ // of bits in a port number!
+ const int MAX_SHORT = 65535;
static int upper_limit = MAX_SHORT;
int lower_limit = IPPORT_RESERVED;
int round_trip = upper_limit;
diff --git a/ace/INET_Addr.cpp b/ace/INET_Addr.cpp
index e73fc1d503a..5a98da7ce94 100644
--- a/ace/INET_Addr.cpp
+++ b/ace/INET_Addr.cpp
@@ -400,6 +400,7 @@ ACE_INET_Addr::get_host_name (void) const
static char buf[MAXHOSTNAMELEN + 1];
::gethostname (buf, MAXHOSTNAMELEN + 1);
+ return buf;
#else
int a_len = sizeof this->inet_addr_.sin_addr.s_addr;
diff --git a/ace/Log_Msg.cpp b/ace/Log_Msg.cpp
index 8a00060ae67..042a450203f 100644
--- a/ace/Log_Msg.cpp
+++ b/ace/Log_Msg.cpp
@@ -65,37 +65,30 @@ ACE_Log_Msg::instance (void)
{
#if defined (ACE_MT_SAFE)
#if defined (VXWORKS)
-
- // TSS Singleton implementation.
-
+ // TSS Singleton implementation for VxWorks.
static int once_ = 0;
- // this isn't thread safe . . .
+ // This isn't thread safe . . .
if (once_ == 0 && lock_ == 0)
{
// Initialize the static recursive lock here. Note that we
// can't rely on the constructor being called at this point.
ACE_NEW_RETURN (lock_, ACE_Recursive_Thread_Mutex, 0);
-
once_ = 1;
}
- // Get the tss_log_msg from thread-specific storage, using one of the
- // "spare" fields in the task control block. Note that no locks
- // are required here...
+ // Get the tss_log_msg from thread-specific storage, using one of
+ // the "spare" fields in the task control block. Note that no locks
+ // are required here since this is within our thread context...
ACE_Log_Msg **tss_log_msg = (ACE_Log_Msg **) &taskIdCurrent->spare1;
// Check to see if this is the first time in for this thread.
if (*(int **) tss_log_msg == 0)
- {
- // Allocate memory off the heap and store it in a pointer in
- // thread-specific storage (on the stack...).
-
- ACE_NEW_RETURN (*tss_log_msg, ACE_Log_Msg, 0);
- }
+ // Allocate memory off the heap and store it in a pointer in
+ // thread-specific storage (on the stack...).
+ ACE_NEW_RETURN (*tss_log_msg, ACE_Log_Msg, 0);
return *tss_log_msg;
-
#elif !defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
#error "Platform must support thread-specific storage if threads are used..."
#else
diff --git a/ace/Map_Manager.cpp b/ace/Map_Manager.cpp
index ffa07a3d750..15651326e20 100644
--- a/ace/Map_Manager.cpp
+++ b/ace/Map_Manager.cpp
@@ -134,7 +134,6 @@ ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::resize_i (size_t size)
size_t i;
ACE_Map_Entry<EXT_ID, INT_ID> *temp = (ACE_Map_Entry<EXT_ID, INT_ID> *) ptr;
- ACE_Map_Entry<EXT_ID, INT_ID> *foo;
// Copy over the currently active elements.
for (i = 0; i < this->cur_size_; i++)
@@ -148,8 +147,8 @@ ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::resize_i (size_t size)
for (i = this->cur_size_; i < this->max_size_; i++)
{
- // call the constructor for each element in the array
- foo = new (&(temp[i])) ACE_Map_Entry<EXT_ID, INT_ID>;
+ // Call the constructor for each element in the array.
+ new (&(temp[i])) ACE_Map_Entry<EXT_ID, INT_ID>;
temp[i].is_free_ = 1;
}
diff --git a/ace/OS.cpp b/ace/OS.cpp
index 6e41a8ff33e..b52c155fe99 100644
--- a/ace/OS.cpp
+++ b/ace/OS.cpp
@@ -562,8 +562,8 @@ public:
// Run the thread exit point. This must be an extern "C" to make
// certain compilers happy...
-extern "C"
-void *ace_thread_adapter (void *args)
+extern "C" void *
+ace_thread_adapter (void *args)
{
// ACE_TRACE ("ACE_Thread_Adapter::svc_run");
ACE_Thread_Adapter *thread_args = (ACE_Thread_Adapter *) args;
@@ -592,7 +592,7 @@ void *ace_thread_adapter (void *args)
/* NOTREACHED */
return status;
#else
- return (*func) (arg); // Call thread entry point.
+ return (void *) (*func) (arg); // Call thread entry point.
#endif /* ACE_WIN32 */
}
@@ -841,7 +841,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
}
}
- p_thr = (thr_id == 0 ? &tmp_thr : thr_id);
+ p_thr = thr_id == 0 ? &tmp_thr : thr_id;
#if defined (ACE_HAS_SETKIND_NP)
ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_create (p_thr, attr, func, args),
@@ -894,7 +894,6 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
ACE_Thread_Adapter *thread_args;
ACE_NEW_RETURN (thread_args, ACE_Thread_Adapter (func, args), -1);
-
#if defined (ACE_HAS_MFC)
if (ACE_BIT_ENABLED (flags, THR_USE_AFX))
{
@@ -946,8 +945,9 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
ACE_FAIL_RETURN (-1);
/* NOTREACHED */
#elif defined (VXWORKS)
- // If thr_id points to NULL (or is 0), the call below causes VxWorks
- // to assign a unique task name of the form: "t" + an integer.
+ // If thr_id points to NULL (or is 0), the call below causes
+ // VxWorks to assign a unique task name of the form: "t" + an
+ // integer.
// args must be an array of _exactly_ 10 ints.
@@ -1078,7 +1078,7 @@ ACE_OS::thr_keyfree (ACE_thread_key_t key)
int
ACE_OS::thr_keycreate (ACE_thread_key_t *key,
- void (*dest) (void *),
+ ACE_THR_DEST dest,
void *inst)
{
// ACE_TRACE ("ACE_OS::thr_keycreate");
diff --git a/ace/OS.h b/ace/OS.h
index 89b7fce5630..463e23162d5 100644
--- a/ace/OS.h
+++ b/ace/OS.h
@@ -184,12 +184,6 @@
#endif /* ACE_HAS_ALLOC_HOOKS */
#if defined (VXWORKS)
-#if defined (ghs)
-// horrible hacks to get around inconsistency between ansi and VxWorks
-// stdarg.h with Green Hills 1.8.8 compiler
-#define __INCstdargh
-#include /**/ <stdarg.h>
-#endif /* ghs */
typedef int key_t;
#include /**/ <vxWorks.h>
@@ -891,8 +885,14 @@ typedef void *ACE_MALLOC_T;
#if defined (ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES)
// Prototypes for both signal() and struct sigaction are consistent..
+#if defined (ACE_HAS_SIG_C_FUNC)
+extern "C" {
+#endif /* ACE_HAS_SIG_C_FUNC */
typedef void (*ACE_SignalHandler)(int);
typedef void (*ACE_SignalHandlerV)(int);
+#if defined (ACE_HAS_SIG_C_FUNC)
+}
+#endif /* ACE_HAS_SIG_C_FUNC */
#elif defined (ACE_HAS_IRIX_53_SIGNALS)
typedef void (*ACE_SignalHandler)(...);
typedef void (*ACE_SignalHandlerV)(...);
@@ -1768,17 +1768,31 @@ union semun
// Create some useful typedefs.
typedef const char **SYS_SIGLIST;
+// This is for C++ static methods.
+#if defined (VXWORKS)
+typedef FUNCPTR ACE_THR_FUNC; // where typedef int (*FUNCPTR) (...)
+#else
typedef void *(*ACE_THR_FUNC)(void *);
+#endif /* VXWORKS */
+
+#if defined (ACE_HAS_THR_C_DEST)
+// Needed for frigging MVS C++...
+extern "C" {
+typedef void (*ACE_THR_DEST)(void *);
+}
+#else
+typedef void (*ACE_THR_DEST)(void *);
+#endif /* ACE_HAS_THR_C_DEST */
extern "C"
{
-#if defined (VXWORKS)
-typedef FUNCPTR ACE_THR_C_FUNC; // where typedef int (*FUNCPTR) (...)
-#elif defined (ACE_WIN32)
+#if defined (ACE_WIN32)
typedef unsigned (__stdcall *ACE_THR_C_FUNC) (void*);
+#elif defined (VXWORKS)
+typedef FUNCPTR ACE_THR_C_FUNC; // where typedef int (*FUNCPTR) (...)
#else
typedef void *(*ACE_THR_C_FUNC)(void *);
-#endif /* ! VXWORKS */
+#endif /* ACE_WIN32 */
}
#if !defined (MAP_FAILED)
@@ -2295,7 +2309,7 @@ public:
static int thr_join (ACE_thread_t waiter_id, ACE_thread_t *thr_id, void **status);
static int thr_keyfree (ACE_thread_key_t key);
static int thr_key_detach (void *inst);
- static int thr_keycreate (ACE_thread_key_t *key, void (*dest)(void *), void *inst = 0);
+ static int thr_keycreate (ACE_thread_key_t *key, ACE_THR_DEST, void *inst = 0);
static int thr_key_used (ACE_thread_key_t key);
static int thr_kill (ACE_thread_t thr_id, int signum);
static size_t thr_min_stack (void);
diff --git a/ace/OS.i b/ace/OS.i
index f877712e511..7fef6bcc600 100644
--- a/ace/OS.i
+++ b/ace/OS.i
@@ -137,9 +137,9 @@ extern "C" char *mktemp (char *);
#if defined (ACE_HAS_THR_C_FUNC)
// This is necessary to work around nasty problems with MVS C++.
extern "C" void ace_mutex_lock_cleanup_adapter (void *args);
-#define ACE_PTHREAD_CLEANUP_PUSH(A) pthread_cleanup_push (ace_mutex_lock_cleanup_adapter, (void *) A));
+#define ACE_PTHREAD_CLEANUP_PUSH(A) pthread_cleanup_push (ace_mutex_lock_cleanup_adapter, (void *) A);
#else
-#define ACE_PTHREAD_CLEANUP_PUSH(A) pthread_cleanup_push (ACE_OS::mutex_lock_cleanup, (void *) A));
+#define ACE_PTHREAD_CLEANUP_PUSH(A) pthread_cleanup_push (ACE_OS::mutex_lock_cleanup, (void *) A);
#endif /* ACE_HAS_THR_C_FUNC */
#if defined (ACE_HAS_REGEX)
@@ -2450,7 +2450,10 @@ ACE_OS::gethostbyname_r (const char *name, hostent *result,
#if defined (VXWORKS)
ACE_NOTSUP_RETURN (0);
#elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && defined (ACE_MT_SAFE) && !defined (UNIXWARE)
-#if defined (AIX) || defined (DIGITAL_UNIX)
+#if defined (DIGITAL_UNIX)
+ // gethostbyname returns thread-specific storage on Digital Unix
+ ACE_SOCKCALL_RETURN (::gethostbyname (name), struct hostent *, 0);
+#elif defined (AIX)
::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
if (::gethostbyname_r (name, result, (struct hostent_data *) buffer) == 0)
@@ -3212,10 +3215,10 @@ ACE_OS::thr_sigsetmask (int how,
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_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsm, osm),
ace_result_), int, -1);
#elif defined (ACE_HAS_PTHREADS) && !defined (ACE_HAS_FSU_PTHREADS)
-#if defined (ACE_HAS_IRIX62_THREADS) || defined (DIGITAL_UNIX)
+#if defined (ACE_HAS_IRIX62_THREADS)
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsm, osm),
ace_result_),int, -1);
#else
@@ -3266,11 +3269,10 @@ ACE_OS::thr_min_stack (void)
#elif (defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS)) && !defined (ACE_HAS_SETKIND_NP)
#if defined (ACE_HAS_IRIX62_THREADS)
return (size_t) ACE_OS::sysconf (_SC_THREAD_STACK_MIN);
-#if defined (PTHREAD_STACK_MIN)
+#elif defined (PTHREAD_STACK_MIN)
return PTHREAD_STACK_MIN;
#else
ACE_NOTSUP_RETURN (0);
-#endif /* PTHREAD_STACK_MIN */
#endif /* ACE_HAS_IRIX62_THREADS */
#elif (defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS)) && !defined (ACE_HAS_SETKIND_NP)
ACE_NOTSUP_RETURN (0);
@@ -4658,7 +4660,7 @@ ACE_OS::asctime_r (const struct tm *t, char *buf, int buflen)
#endif /* ACE_HAS_ONLY_TWO_PARAMS_FOR_ASCTIME_R_AND_CTIME_R */
#else
char *result;
- ACE_OSCALL_RETURN (::asctime (t), char *, 0);
+ ACE_OSCALL (::asctime (t), char *, 0, result);
::strncpy (buf, result, buflen);
return buf;
#endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && defined (ACE_MT_SAFE) */
@@ -5235,6 +5237,8 @@ ACE_OS::mkdir (const char *path, mode_t mode)
// ACE_TRACE ("ACE_OS::mkdir");
#if defined (ACE_WIN32)
ACE_OSCALL_RETURN (::_mkdir (path), int, -1);
+#elif defined (VXWORKS)
+ 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 027ba172c92..8101c915453 100644
--- a/ace/Pipe.cpp
+++ b/ace/Pipe.cpp
@@ -39,9 +39,8 @@ ACE_Pipe::open (void)
{
ACE_INET_Addr sv_addr (my_addr.get_port_number (), "localhost");
- // Establish a connection within the same process, make sure to
- // enable the "reuse addr" flag.
- if (connector.connect (writer, sv_addr, 0, ACE_Addr::sap_any, 1) == -1)
+ // Establish a connection within the same process.
+ if (connector.connect (writer, sv_addr) == -1)
result = -1;
else if (acceptor.accept (reader) == -1)
{
@@ -50,6 +49,7 @@ ACE_Pipe::open (void)
}
}
+#if !defined (VXWORKS)
int one = 1;
// Make sure that the TCP stack doesn't try to buffer small writes.
// Since this communication is purely local to the host it doesn't
@@ -57,6 +57,7 @@ ACE_Pipe::open (void)
if (writer.set_option (IPPROTO_TCP, TCP_NODELAY,
&one, sizeof one) == -1)
return -1;
+#endif /* !VXWORKS */
// Close down the acceptor endpoint since we don't need it anymore.
acceptor.close ();
diff --git a/ace/README b/ace/README
index 9b3ca25721c..fbcca13ce6f 100644
--- a/ace/README
+++ b/ace/README
@@ -73,6 +73,7 @@ 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_SIG_C_FUNC Compiler requires extern "C" functions for signals.
ACE_HAS_SIN_LEN Platform supports new BSD inet_addr len field.
ACE_HAS_SIZET_SOCKET_LEN OS/compiler uses size_t * rather than int * for socket lengths
ACE_HAS_SOCKIO_H Compiler/platform provides the sockio.h file
@@ -107,6 +108,7 @@ ACE_HAS_TEMPLATE_TYPEDEFS Compiler implements templates that support typedefs i
ACE_HAS_TERM_IOCTLS Platform has terminal ioctl flags like TCGETS and TCSETS.
ACE_HAS_THREADS Platform supports threads
ACE_HAS_THREAD_SPECIFIC_STORAGE Compiler/platform has thread-specific storage
+ACE_HAS_THR_C_DEST The pthread_keycreate() routine *must* take extern C functions.
ACE_HAS_THR_C_FUNC The pthread_create() routine *must* take extern C functions.
ACE_HAS_TID_T Platform supports the tid_t type (e.g., AIX)
ACE_HAS_TIMEZONE_GETTIMEOFDAY Platform/compiler supports timezone * as second parameter to gettimeofday()
diff --git a/ace/Reactor.cpp b/ace/Reactor.cpp
index 214ed466c93..3572ffea70f 100644
--- a/ace/Reactor.cpp
+++ b/ace/Reactor.cpp
@@ -859,6 +859,13 @@ ACE_Reactor::open (size_t size,
this->delete_signal_handler_ = 0;
}
+ // We do this first in case the handler_rep_ call fails (which it
+ // sometimes does on Win32 when we restart applications quickly due
+ // to the use of sockets as a notification mechanism). At least
+ // this way the timer_queue_ isn't 0, so we can still use the
+ // Reactor as a timer...
+ ACE_NEW_RETURN (this->timer_queue_, ACE_Timer_Queue, -1);
+
if (this->handler_rep_.open (size) == -1)
return -1;
#if defined (ACE_MT_SAFE)
@@ -870,8 +877,6 @@ ACE_Reactor::open (size_t size,
}
#endif /* ACE_MT_SAFE */
- ACE_NEW_RETURN (this->timer_queue_, ACE_Timer_Queue, -1);
-
#if defined (ACE_USE_POLL)
ACE_NEW_RETURN (this->poll_h_, pollfd[size], -1);
diff --git a/ace/Reactor.h b/ace/Reactor.h
index fe178877950..87de350c5b0 100644
--- a/ace/Reactor.h
+++ b/ace/Reactor.h
@@ -1,7 +1,6 @@
/* -*- C++ -*- */
// $Id$
-
// ============================================================================
//
// = LIBRARY
diff --git a/ace/Service_Main.cpp b/ace/Service_Main.cpp
index cf20fe799e8..f6d4ea1a4df 100644
--- a/ace/Service_Main.cpp
+++ b/ace/Service_Main.cpp
@@ -1,37 +1,33 @@
// Service_Main.cpp
// $Id$
-/* This is an example of a canonical Service Configurator daemon's
- main() function. Note how this driver file is completely generic
- and may be used to configure almost any type of network daemon. */
+// This is an example of a canonical Service Configurator daemon's
+// main() function. Note how this driver file is completely generic
+// and may be used to configure almost any type of network daemon.
#define ACE_BUILD_DLL
#include "ace/Service_Config.h"
-sig_atomic_t finished = 0;
-
-static void
-handler (int)
-{
- ACE_TRACE ("handler");
- finished = 1;
-}
-
int
sc_main (int argc, char *argv[])
{
ACE_TRACE ("sc_main");
ACE_Service_Config daemon;
- ACE_OS::signal (SIGINT, ACE_SignalHandler (handler));
-
if (daemon.open (argc, argv) == -1)
ACE_ERROR ((LM_ERROR, "%p\n%a", "open", 1));
- /* Run forever, performing the configured services. */
+ // Create an adapter to end the 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);
+
+ // Run forever, performing the configured services until we are shut
+ // down by a SIGINT/SIGQUIT signal.
- while (!finished)
- daemon.run_reactor_event_loop ();
+ while (server_test.reactor_event_loop_done () == 0)
+ server_test.run_reactor_event_loop ();
return 0;
}
diff --git a/ace/Signal.cpp b/ace/Signal.cpp
index 8232c639e72..2354ec34a19 100644
--- a/ace/Signal.cpp
+++ b/ace/Signal.cpp
@@ -11,6 +11,26 @@
// Static definitions.
+#if defined (ACE_HAS_SIG_C_FUNC)
+extern "C" void
+ace_signal_handler_dispatch (int signum, siginfo_t *info, ucontext_t *context)
+{
+ ACE_TRACE ("ace_signal_handler_dispatch");
+ ACE_Sig_Handler::dispatch (signum, info, context);
+}
+
+extern "C" void
+ace_signal_handlers_dispatch (int, siginfo_t *, ucontext_t *)
+{
+ ACE_TRACE ("ace_signal_handlers_dispatch");
+ ACE_Sig_Handlers::dispatch (signum, info, context);
+}
+
+static ACE_SignalHandler ace_dispatcher = ACE_SignalHandler (ace_signal_handlers_dispatch);
+#else
+static ACE_SignalHandler ace_dispatcher = ACE_SignalHandler (ACE_Sig_Handler::dispatch);
+#endif /* ACE_HAS_SIG_C_FUNC */
+
#if defined (ACE_MT_SAFE)
ACE_Recursive_Thread_Mutex ACE_Sig_Handler::ace_sig_handler_lock_;
#endif /* ACE_MT_SAFE */
@@ -165,7 +185,7 @@ ACE_Sig_Handler::register_handler (int signum,
if (new_disp == 0)
new_disp = &sa;
- new_disp->handler (ACE_SignalHandler (ACE_Sig_Handler::dispatch));
+ new_disp->handler (ace_dispatcher);
new_disp->flags (new_disp->flags () | SA_SIGINFO);
return new_disp->register_action (signum, old_disp);
}
@@ -388,7 +408,7 @@ ACE_Sig_Handlers::register_handler (int signum,
// Check whether we are already in control of the signal
// handling disposition...
- if (!(sa.handler () == ACE_SignalHandler (ACE_Sig_Handlers::dispatch)
+ if (!(sa.handler () == ace_dispatcher
|| sa.handler () == ACE_SignalHandler (SIG_IGN)
|| sa.handler () == ACE_SignalHandler (SIG_DFL)))
{
@@ -437,7 +457,7 @@ ACE_Sig_Handlers::register_handler (int signum,
return -1;
}
// If ACE_Sig_Handler::dispatch() was set we're done.
- else if (sa.handler () == ACE_SignalHandler (ACE_Sig_Handlers::dispatch))
+ else if (sa.handler () == ace_dispatcher)
return ace_sig_adapter->sigkey ();
// Otherwise, we need to register our handler function so that
@@ -449,7 +469,7 @@ ACE_Sig_Handlers::register_handler (int signum,
if (new_disp == 0)
new_disp = &sa;
- new_disp->handler (ACE_SignalHandler (ACE_Sig_Handlers::dispatch));
+ new_disp->handler (ace_dispatcher);
// Default is to restart signal handlers.
new_disp->flags (new_disp->flags () | SA_RESTART);
diff --git a/ace/Signal.h b/ace/Signal.h
index e12b18fdc1e..f627bd73222 100644
--- a/ace/Signal.h
+++ b/ace/Signal.h
@@ -199,6 +199,11 @@ public:
// Set a new <ACE_Event_Handler> that is associated with <signum>.
// Return the existing handler.
+ static void dispatch (int, siginfo_t *, ucontext_t *);
+ // Callback routine registered with sigaction(2) that dispatches the
+ // handle_signal() method of the appropriate pre-registered
+ // ACE_Event_Handler.
+
void dump (void) const;
// Dump the state of an object.
@@ -219,11 +224,6 @@ protected:
#endif /* ACE_MT_SAFE */
private:
- static void dispatch (int, siginfo_t *, ucontext_t *);
- // Callback routine registered with sigaction(2) that dispatches the
- // handle_signal() method of the appropriate pre-registered
- // ACE_Event_Handler.
-
static ACE_Event_Handler *signal_handlers_[NSIG];
// Array used to store one user-defined Event_Handler for every
// signal.
@@ -319,6 +319,11 @@ public:
// head of the list of signals. Return the existing handler that
// was at the head.
+ static void dispatch (int signum, siginfo_t *, ucontext_t *);
+ // Callback routine registered with sigaction(2) that dispatches the
+ // handle_signal() method of all the pre-registered
+ // ACE_Event_Handlers for <signum>
+
void dump (void) const;
// Dump the state of an object.
@@ -326,11 +331,6 @@ public:
// Declare the dynamic allocation hooks.
private:
- static void dispatch (int signum, siginfo_t *, ucontext_t *);
- // Callback routine registered with sigaction(2) that dispatches the
- // handle_signal() method of all the pre-registered
- // ACE_Event_Handlers for <signum>
-
static int sigkey_;
// Keeps track of the id that uniquely identifies each registered
// signal handler. This id can be used to cancel a timer via the
diff --git a/ace/Thread.h b/ace/Thread.h
index 4880b824f8e..02f8f1d8e46 100644
--- a/ace/Thread.h
+++ b/ace/Thread.h
@@ -119,7 +119,7 @@ public:
// Change and/or examine calling thread's signal mask.
static int keycreate (ACE_thread_key_t *keyp,
- void (*destructor)(void *value),
+ ACE_THR_DEST destructor,
void * = 0);
// Allocates a <keyp> that is used to identify data that is specific
// to each thread in the process. The key is global to all threads
diff --git a/ace/Thread.i b/ace/Thread.i
index 88d2b1bfcf2..f22927e171c 100644
--- a/ace/Thread.i
+++ b/ace/Thread.i
@@ -9,7 +9,7 @@
ACE_INLINE int
ACE_Thread::keycreate (ACE_thread_key_t *keyp,
- void (*destructor)(void *value),
+ ACE_THR_DEST destructor,
void *inst)
{
ACE_TRACE ("ACE_Thread::keycreate");
diff --git a/ace/Thread_Manager.i b/ace/Thread_Manager.i
index a2cbc04b53c..5cb1444d5b4 100644
--- a/ace/Thread_Manager.i
+++ b/ace/Thread_Manager.i
@@ -74,7 +74,7 @@ ACE_Thread_Control::thr_mgr (ACE_Thread_Manager *tm)
{
ACE_TRACE ("ACE_Thread_Control::thr_mgr");
ACE_Thread_Manager *o_tm = this->tm_;
- return this->tm_ = tm;
+ this->tm_ = tm;
return o_tm;
}
diff --git a/ace/Time_Request_Reply.cpp b/ace/Time_Request_Reply.cpp
index 46bce6553c6..2234e960d22 100644
--- a/ace/Time_Request_Reply.cpp
+++ b/ace/Time_Request_Reply.cpp
@@ -103,7 +103,7 @@ ACE_Time_Request::timeout (const ACE_Time_Value timeout)
}
// = Set/get the time
-const ACE_UINT32
+ACE_UINT32
ACE_Time_Request::time (void) const
{
ACE_TRACE ("ACE_Time_Request::time");
@@ -111,7 +111,7 @@ ACE_Time_Request::time (void) const
}
void
-ACE_Time_Request::time (const ACE_UINT32 t)
+ACE_Time_Request::time (ACE_UINT32 t)
{
ACE_TRACE ("ACE_Time_Request::time");
this->time_ = t;
diff --git a/ace/Time_Request_Reply.h b/ace/Time_Request_Reply.h
index 7bd3219d6e7..ce78fe3b0cc 100644
--- a/ace/Time_Request_Reply.h
+++ b/ace/Time_Request_Reply.h
@@ -64,8 +64,8 @@ public:
void msg_type (ACE_UINT32);
// = Set/get the time
- const ACE_UINT32 time (void) const;
- void time (const ACE_UINT32 t);
+ ACE_UINT32 time (void) const;
+ void time (ACE_UINT32 t);
// = Set/get the blocking semantics.
ACE_UINT32 block_forever (void) const;
diff --git a/ace/UPIPE_Stream.cpp b/ace/UPIPE_Stream.cpp
index 8f1b29a8596..b5fba065f27 100644
--- a/ace/UPIPE_Stream.cpp
+++ b/ace/UPIPE_Stream.cpp
@@ -92,7 +92,7 @@ ACE_UPIPE_Stream::send (const char *buffer,
ACE_NEW_RETURN (mb_p, ACE_Message_Block (n), -1);
mb_p->copy (buffer, n);
- return this->stream_.put (mb_p, timeout) == -1 ? -1 : n;
+ return this->stream_.put (mb_p, timeout) == -1 ? -1 : (int) n;
}
// Receive a buffer.
diff --git a/ace/config-mvs.h b/ace/config-mvs.h
index c2eb04ab54f..506f35a03a3 100644
--- a/ace/config-mvs.h
+++ b/ace/config-mvs.h
@@ -16,6 +16,9 @@
// Compiler/platform uses macro for ctime
#define ACE_HAS_BROKEN_CTIME
+// Compiler requires extern "C" functions for signals.
+#define ACE_HAS_SIG_C_FUNC
+
// Prototypes for both signal() and struct sigaction are consistent.
#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES
@@ -28,6 +31,9 @@
// The pthread_create() routine *must* take extern C functions.
#define ACE_HAS_THR_C_FUNC
+// The pthread_keycreate() routine *must* take extern C functions.
+#define ACE_HAS_THR_C_DEST
+
// The rusage_t structure has only two fields
#define ACE_HAS_LIMITED_RUSAGE_T
diff --git a/examples/Logger/simple-server/server_loggerd.cpp b/examples/Logger/simple-server/server_loggerd.cpp
index 7397fc501e2..a94aef775b0 100644
--- a/examples/Logger/simple-server/server_loggerd.cpp
+++ b/examples/Logger/simple-server/server_loggerd.cpp
@@ -14,7 +14,7 @@
static sig_atomic_t finished = 0;
-static void
+extern "C" void
handler (int)
{
finished = 1;
@@ -26,11 +26,13 @@ static const u_short PORT = ACE_DEFAULT_SERVER_PORT;
int
main (int argc, char *argv[])
{
+ // Register a signal handler.
+ ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT);
+
Logging_Acceptor peer_acceptor;
ACE_INET_Addr addr (PORT);
- ACE_Get_Opt get_opt (argc, argv, "p:");
- ACE_Sig_Action sig ((ACE_SignalHandler) handler, SIGINT);
+ ACE_Get_Opt get_opt (argc, argv, "p:");
for (int c; (c = get_opt ()) != -1; )
switch (c)
diff --git a/examples/Mem_Map/IO-tests/test_io.cpp b/examples/Mem_Map/IO-tests/test_io.cpp
index 4615eec60e2..e209534929e 100644
--- a/examples/Mem_Map/IO-tests/test_io.cpp
+++ b/examples/Mem_Map/IO-tests/test_io.cpp
@@ -1,6 +1,6 @@
-/* Test program for different methods of copying files. */
// $Id$
+// Test program for different methods of copying files.
#include "ace/OS.h"
#include "ace/Profile_Timer.h"
@@ -8,25 +8,25 @@
#include "ace/Signal.h"
#include "IO_Test.h"
-/* Name of program. */
+// Name of program.
static char *program_name;
-/* Name of default input file. */
+// Name of default input file.
static char *input_filename = "/usr/dict/words";
-/* Name of default output file. */
+// Name of default output file.
static char *output_filename = "/tmp/foo";
-/* Check if removing output file upon completion... */
+// Check if removing output file upon completion...
static int remove_output = 1;
-/* Count of the number of iterations to run the tests. */
+// Count of the number of iterations to run the tests.
static int iteration_count = 100;
-/* Profiler used to keep track of file I/O time. */
+// Profiler used to keep track of file I/O time.
static ACE_Profile_Timer tm;
-/* Explain usage and exit. */
+// Explain usage and exit.
static void
print_usage_and_die (void)
@@ -37,17 +37,17 @@ print_usage_and_die (void)
ACE_OS::exit (1);
}
-/* Clean up the output file on exit from a signal. */
+// Clean up the output file on exit from a signal.
-static void
-clean_up (int = 0)
+extern "C" void
+cleanup (int = 0)
{
if (remove_output)
ACE_OS::unlink (output_filename);
ACE_OS::exit (0);
}
-/* Set up the program name used in error messages. */
+// Set up the program name used in error messages.
static void
set_program_name (char name[])
@@ -58,7 +58,7 @@ set_program_name (char name[])
program_name = name + 1;
}
-/* Parse the command-line arguments and set options. */
+// Parse the command-line arguments and set options.
static void
parse_args (int argc, char *argv[])
@@ -86,7 +86,7 @@ parse_args (int argc, char *argv[])
}
}
-/* Vector of pointers to derived classes that inherit from IO_Test base class. */
+// Vector of pointers to derived classes that inherit from IO_Test base class.
static IO_Test *test_vector[100];
@@ -99,7 +99,7 @@ run_tests (int iterations, FILE *input_fp, FILE *output_fp)
test_vector[2] = new Block_Read_Write_Test ("Block_Read_Write_Test", tm);
test_vector[3] = new Mmap1_Test ("Mmap1_Test", tm);
test_vector[4] = new Mmap2_Test ("Mmap2_Test", tm);
- /* test_vector[5] = new Slow_Read_Write_Test ("Slow"Read_Write_Test", tm) */
+ // test_vector[5] = new Slow_Read_Write_Test ("Slow"Read_Write_Test", tm)
test_vector[5] = (IO_Test *) 0;
for (int i = 0; test_vector[i] != 0; i++)
@@ -135,7 +135,8 @@ main (int argc, char *argv[])
set_program_name (argv[0]);
parse_args (argc, argv);
- ACE_Sig_Action sig ((ACE_SignalHandler) clean_up, SIGINT);
+
+ ACE_Sig_Action sa ((ACE_SignalHandler) cleanup, SIGINT);
if ((input_fp = ACE_OS::fopen (input_filename, "r")) == 0)
ACE_OS::perror (input_filename), ACE_OS::exit (1);
@@ -150,6 +151,6 @@ main (int argc, char *argv[])
if (ACE_OS::fclose (input_fp) == -1 || ACE_OS::fclose (output_fp) == -1)
ACE_OS::perror ("fclose"), ACE_OS::exit (1);
- clean_up ();
+ cleanup ();
return 0;
}
diff --git a/examples/Reactor/Misc/test_signals_2.cpp b/examples/Reactor/Misc/test_signals_2.cpp
index 7a446e05aac..8054ef7d410 100644
--- a/examples/Reactor/Misc/test_signals_2.cpp
+++ b/examples/Reactor/Misc/test_signals_2.cpp
@@ -173,8 +173,7 @@ public:
ACE_DEBUG ((LM_DEBUG, "\nshutting down SIGQUIT in Sig_Handler_2 (%s, %d, %d)",
this->msg_, this->int_sigkey_, this->quit_sigkey_));
}
- else
- return 0;
+ return 0;
}
};
@@ -198,6 +197,7 @@ main (int argc, char *argv)
{
// Register an "external" signal handler so that the
// ACE_Sig_Handlers code will have something to incorporate!
+
ACE_SignalHandler eh = ACE_SignalHandler (external_handler);
ACE_Sig_Action sa (eh);
diff --git a/examples/Reactor/Ntalker/ntalker.cpp b/examples/Reactor/Ntalker/ntalker.cpp
index e49c94eedf0..5c0bc4f395d 100644
--- a/examples/Reactor/Ntalker/ntalker.cpp
+++ b/examples/Reactor/Ntalker/ntalker.cpp
@@ -152,7 +152,7 @@ static sig_atomic_t done = 0;
// Signal handler.
-static void
+extern "C" void
handler (int)
{
done = 1;
@@ -161,7 +161,8 @@ handler (int)
int
main (int argc, char *argv[])
{
- ACE_Sig_Action sig ((ACE_SignalHandler) handler, SIGINT);
+ ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT);
+
parse_args (argc, argv);
ACE_Reactor reactor;
diff --git a/examples/Reactor/ReactorEx/test_reactorEx.cpp b/examples/Reactor/ReactorEx/test_reactorEx.cpp
index 62143956f9c..170e0f69e4b 100644
--- a/examples/Reactor/ReactorEx/test_reactorEx.cpp
+++ b/examples/Reactor/ReactorEx/test_reactorEx.cpp
@@ -324,6 +324,7 @@ STDIN_Handler::STDIN_Handler (MT_TASK &ph)
// exception so that the kernel doesn't kill our process.
// Registering this signal handler just tells the kernel that we
// know what we're doing; to leave us alone.
+
ACE_OS::signal (SIGINT, ACE_SignalHandler (STDIN_Handler::handler));
};
diff --git a/examples/Reactor/WFMO_Reactor/test_reactorEx.cpp b/examples/Reactor/WFMO_Reactor/test_reactorEx.cpp
index 62143956f9c..170e0f69e4b 100644
--- a/examples/Reactor/WFMO_Reactor/test_reactorEx.cpp
+++ b/examples/Reactor/WFMO_Reactor/test_reactorEx.cpp
@@ -324,6 +324,7 @@ STDIN_Handler::STDIN_Handler (MT_TASK &ph)
// exception so that the kernel doesn't kill our process.
// Registering this signal handler just tells the kernel that we
// know what we're doing; to leave us alone.
+
ACE_OS::signal (SIGINT, ACE_SignalHandler (STDIN_Handler::handler));
};
diff --git a/examples/Service_Configurator/IPC-tests/server/server_test.cpp b/examples/Service_Configurator/IPC-tests/server/server_test.cpp
index f65523d956d..451f178e256 100644
--- a/examples/Service_Configurator/IPC-tests/server/server_test.cpp
+++ b/examples/Service_Configurator/IPC-tests/server/server_test.cpp
@@ -1,31 +1,28 @@
-/* The main test driver for the dynamically configured server. */
// $Id$
+// The main test driver for the dynamically configured server.
#include "ace/Service_Config.h"
-sig_atomic_t finished = 0;
-
-static void
-handler (int)
-{
- finished = 1;
-}
-
int
main (int argc, char *argv[])
{
ACE_Service_Config server_test;
- ACE_Sig_Action sig ((ACE_SignalHandler) handler, SIGINT);
-
if (server_test.open (argc, argv) == -1)
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "server_test.open"), -1);
- for (;;)
- if (server_test.run_reactor_event_loop () == -1 && finished)
- break;
+ // Create an adapter to end the 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);
+
+ // 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 ();
- /* NOTREACHED */
return 0;
}
diff --git a/examples/Shared_Malloc/test_malloc.cpp b/examples/Shared_Malloc/test_malloc.cpp
index 508644adb48..694e534251b 100644
--- a/examples/Shared_Malloc/test_malloc.cpp
+++ b/examples/Shared_Malloc/test_malloc.cpp
@@ -1,6 +1,6 @@
-// This program tests out all the various ACE_Malloc combinations and
// $Id$
+// This program tests out all the various ACE_Malloc combinations and
// the ACE_Allocator_Adapter.
#include "ace/Thread.h"
@@ -157,7 +157,7 @@ wait_for_children (void)
#endif /* ACE_WIN32 */
}
-static void
+extern "C" void
handler (int)
{
Malloc::instance ()->remove ();
@@ -167,7 +167,8 @@ handler (int)
int
main (int argc, char *argv[])
{
- signal (SIGINT, ACE_SignalHandler (handler));
+ // Register a signal handler.
+ ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT);
Options::instance ()->parse_args (argc, argv);
diff --git a/examples/System_V_IPC/SV_Message_Queues/MQ_Server.cpp b/examples/System_V_IPC/SV_Message_Queues/MQ_Server.cpp
index 39680dd91bc..ee5f39f7efb 100644
--- a/examples/System_V_IPC/SV_Message_Queues/MQ_Server.cpp
+++ b/examples/System_V_IPC/SV_Message_Queues/MQ_Server.cpp
@@ -1,14 +1,14 @@
-#include "ace/Signal.h"
// $Id$
+#include "ace/Signal.h"
#include "ace/SV_Message_Queue.h"
#include "test.h"
-/* Must be global for signal Message... */
-ACE_SV_Message_Queue msgque (SRV_KEY, ACE_SV_Message_Queue::ACE_CREATE);
+// Must be global for signal Message...
+static ACE_SV_Message_Queue msgque (SRV_KEY, ACE_SV_Message_Queue::ACE_CREATE);
-void
-SIGNAL_handler (int)
+extern "C" void
+handler (int)
{
if (msgque.remove () < 0)
ACE_OS::perror ("msgque.close"), ACE_OS::exit (1);
@@ -23,7 +23,8 @@ main (void)
ACE_Message_Block send_msg (0, pid, ACE_OS::cuserid (0),
"I received your message.");
- ACE_Sig_Action sig ((ACE_SignalHandler) SIGNAL_handler, SIGINT);
+ // Register a signal handler.
+ ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT);
for (;;)
{
diff --git a/examples/System_V_IPC/SV_Message_Queues/TMQ_Server.cpp b/examples/System_V_IPC/SV_Message_Queues/TMQ_Server.cpp
index 185c630ad4a..210ffe199c3 100644
--- a/examples/System_V_IPC/SV_Message_Queues/TMQ_Server.cpp
+++ b/examples/System_V_IPC/SV_Message_Queues/TMQ_Server.cpp
@@ -1,16 +1,16 @@
-#include "ace/Signal.h"
// $Id$
+#include "ace/Signal.h"
#include "ace/Typed_SV_Message_Queue.h"
#include "ace/Log_Msg.h"
#include "test.h"
// Must be global for signal Message...
-ACE_Typed_SV_Message_Queue<Message_Data> msgque
+static ACE_Typed_SV_Message_Queue<Message_Data> msgque
(SRV_KEY, ACE_Typed_SV_Message_Queue<Message_Data>::ACE_CREATE);
-void
-SIGNAL_handler (int)
+extern "C" void
+handler (int)
{
if (msgque.remove () < 0)
ACE_ERROR ((LM_ERROR, "%p\n%a", "msgque.recv", 1));
@@ -25,7 +25,8 @@ main (void)
ACE_Typed_SV_Message<Message_Data> send_msg (msg_data, 0, msg_data.length ());
ACE_Typed_SV_Message<Message_Data> recv_msg (SRV_ID);
- ACE_Sig_Action sig2 ((ACE_SignalHandler) SIGNAL_handler, SIGINT);
+ // Register a signal handler.
+ ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT);
for (;;)
{
diff --git a/examples/System_V_IPC/SV_Semaphores/Semaphore_Server.cpp b/examples/System_V_IPC/SV_Semaphores/Semaphore_Server.cpp
index 3dec989ec52..eda16178483 100644
--- a/examples/System_V_IPC/SV_Semaphores/Semaphore_Server.cpp
+++ b/examples/System_V_IPC/SV_Semaphores/Semaphore_Server.cpp
@@ -1,16 +1,16 @@
-#include "ace/Log_Msg.h"
// $Id$
+#include "ace/Log_Msg.h"
#include "ace/SV_Shared_Memory.h"
#include "ace/SV_Semaphore_Simple.h"
#include "ace/Signal.h"
#include "Semaphore_Test.h"
-ACE_SV_Shared_Memory shm_server (SHM_KEY, SHMSZ, ACE_SV_Shared_Memory::ACE_CREATE);
-ACE_SV_Semaphore_Simple sem (SEM_KEY_1, ACE_SV_Semaphore_Simple::ACE_CREATE, 0, 2);
+static ACE_SV_Shared_Memory shm_server (SHM_KEY, SHMSZ, ACE_SV_Shared_Memory::ACE_CREATE);
+static ACE_SV_Semaphore_Simple sem (SEM_KEY_1, ACE_SV_Semaphore_Simple::ACE_CREATE, 0, 2);
-static void
-cleanup (int = 0)
+extern "C" void
+cleanup (int)
{
if (shm_server.remove () < 0 || sem.remove () < 0)
ACE_ERROR ((LM_ERROR, "%p\n%a", "remove", 1));
@@ -20,7 +20,8 @@ cleanup (int = 0)
int
main (void)
{
- ACE_Sig_Action sig ((ACE_SignalHandler) cleanup, SIGINT);
+ // Register a signal handler.
+ ACE_Sig_Action sa ((ACE_SignalHandler) cleanup, SIGINT);
char *s = (char *) shm_server.get_segment_ptr ();
diff --git a/examples/Threads/test_process_mutex.cpp b/examples/Threads/test_process_mutex.cpp
index 35e5d26ad54..8f7442e36e8 100644
--- a/examples/Threads/test_process_mutex.cpp
+++ b/examples/Threads/test_process_mutex.cpp
@@ -1,7 +1,7 @@
-// This program tests ACE_Process_Mutexes. To run it, open 3
// $Id$
-// or 4 windows and run this program in each window...
+// This program tests ACE_Process_Mutexes. To run it, open 3 or 4
+// windows and run this program in each window...
#include "ace/Log_Msg.h"
#include "ace/Synch.h"
@@ -11,7 +11,7 @@
static sig_atomic_t done;
-static void
+extern "C" void
handler (int)
{
done = 1;
@@ -20,12 +20,15 @@ handler (int)
int
main (int argc, char *argv[])
{
- char *name = argc == 1 ? "hello" : argv[1];
+ char *name = argc > 1 ? argv[1] : "hello";
+ int iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : 100;
ACE_Process_Mutex pm (name);
- ACE_Sig_Action handle ((ACE_SignalHandler) handler, SIGINT);
- for (int i = 0; i < 100 && !done; i++)
+ // Register a signal handler.
+ ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT);
+
+ for (int i = 0; i < iterations && !done; i++)
{
ACE_DEBUG ((LM_DEBUG, "(%P|%t) = acquiring\n"));
if (pm.acquire () == -1)
diff --git a/examples/Threads/test_process_semaphore.cpp b/examples/Threads/test_process_semaphore.cpp
index e96513e5707..b1309400d29 100644
--- a/examples/Threads/test_process_semaphore.cpp
+++ b/examples/Threads/test_process_semaphore.cpp
@@ -1,7 +1,7 @@
-// This program tests ACE_Process_Semaphore. To run it, open 3
// $Id$
-// or 4 windows and run this program in each window...
+// This program tests ACE_Process_Semaphore. To run it, open 3 or 4
+// windows and run this program in each window...
#include "ace/Log_Msg.h"
#include "ace/Synch.h"
@@ -9,7 +9,7 @@
static sig_atomic_t done;
-static void
+extern "C" void
handler (int)
{
done = 1;
@@ -22,7 +22,7 @@ main (int argc, char *argv[])
ACE_Process_Semaphore pm (1, name);
- ACE_Sig_Action handle ((ACE_SignalHandler) handler, SIGINT);
+ ACE_Sig_Action sa (ACE_SignalHandler (handler), SIGINT);
for (int i = 0; i < 100 && !done; i++)
{
diff --git a/examples/Threads/test_task_three.cpp b/examples/Threads/test_task_three.cpp
index a49094525c4..78e9a006321 100644
--- a/examples/Threads/test_task_three.cpp
+++ b/examples/Threads/test_task_three.cpp
@@ -92,7 +92,6 @@ Test_Task::put (ACE_Message_Block *, ACE_Time_Value *)
return 0;
}
-int
Test_Task::svc (void)
{
// Every thread must register the same stream to write to file.
@@ -104,7 +103,7 @@ Test_Task::svc (void)
for (int index = 0; index < NUM_INVOCATIONS; index++)
{
- ACE_OS::thr_yield ();
+ ACE_OS::thr_extern "C" yield ();
if (r_->notify (this, ACE_Event_Handler::READ_MASK))
{
@@ -162,8 +161,8 @@ dispatch (void *arg)
return 0;
}
-static void
-handler (int signum)
+extern "C" void
+handler (int)
{
*out_stream << flush;
out_stream->close ();
@@ -179,9 +178,11 @@ main (int argc, char **argv)
out_stream = new ofstream ("test_task_three.out", ios::trunc|ios::out);
ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM);
ACE_LOG_MSG->msg_ostream (out_stream);
- signal (SIGINT, ACE_SignalHandler (handler));
}
+ // Register a signal handler.
+ ACE_Sig_Action sa (ACE_Sig_Handler_Ex (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 25db53b27a3..a09db55dd51 100644
--- a/examples/Threads/test_thread_manager.cpp
+++ b/examples/Threads/test_thread_manager.cpp
@@ -1,6 +1,6 @@
-// Test out the group management mechanisms provided by the
// $Id$
+// Test out the group management mechanisms provided by the
// ACE_Thread_Manager, including the group signal handling, group
// suspension and resumption, and cooperative thread cancellation
// mechanisms.
@@ -10,7 +10,7 @@
#if defined (ACE_HAS_THREADS)
-static void
+extern "C" void
handler (int signum)
{
ACE_DEBUG ((LM_DEBUG, "(%t) received signal %d\n", signum));
@@ -53,9 +53,8 @@ main (int argc, char *argv[])
daemon.open (argv[0]);
- // Register a signal handler
- ACE_SignalHandler sh (handler);
- ACE_Sig_Action sa (sh, SIGINT);
+ // Register a signal handler.
+ ACE_Sig_Action sa (ACE_Sig_Handler_Ex (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/examples/Threads/test_thread_specific.cpp b/examples/Threads/test_thread_specific.cpp
index 74bedad70d7..41b70c8c012 100644
--- a/examples/Threads/test_thread_specific.cpp
+++ b/examples/Threads/test_thread_specific.cpp
@@ -170,7 +170,7 @@ worker (void *c)
return 0;
}
-static void
+extern "C" void
handler (int signum)
{
ACE_DEBUG ((LM_DEBUG, "signal = %S\n", signum));
@@ -180,15 +180,15 @@ handler (int signum)
int
main (int argc, char *argv[])
{
- // The Service_Config must *always* be the first object defined in
- // main...
+ // The Service_Config must be the first object defined in main...
ACE_Service_Config daemon (argv[0]);
ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ());
int threads = argc > 1 ? ACE_OS::atoi (argv[1]) : 4;
int count = argc > 2 ? ACE_OS::atoi (argv[2]) : 10000;
- signal (SIGINT, ACE_SignalHandler (handler));
-
+ // Register a signal handler.
+ ACE_Sig_Action sa ((ACE_SignalHandler) (handler), SIGINT);
+
#if defined (ACE_HAS_THREADS)
if (ACE_Service_Config::thr_mgr ()->spawn_n (threads,
ACE_THR_FUNC (&worker),