From 4184de21014678975db78438be255cd73af39627 Mon Sep 17 00:00:00 2001 From: schmidt Date: Fri, 17 Apr 1998 02:20:59 +0000 Subject: *** empty log message *** --- ChangeLog-98a | 16 ++++++++++++++++ ace/Signal.cpp | 15 +++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/ChangeLog-98a b/ChangeLog-98a index b9eb9714cc0..e045856d61c 100644 --- a/ChangeLog-98a +++ b/ChangeLog-98a @@ -1,3 +1,19 @@ +Thu Apr 16 21:12:48 1998 Douglas C. Schmidt + + * ace/Signal.cpp: There was a major portability violation in the + ACE_Sig_Handler::dispatch() method, which was previously + acquiring a mutex lock. This is NOT permitted in the POSIX + signal handler spec. In addition, the implementation had other + nasty consequences related to dynamic allocation of memory in + the signal handler, which has a bad habit of breaking + non-reentrant uses of "new". The consequence of all this is + that you really shouldn't be modifying signal handlers via the + Reactor in multiple threads of control. In general, threads and + signals are just plain evil, so they are best addressed via + sigwait() anyhow... + + Thanks to Sumedh and Naga for first tracking this down. + Thu Apr 16 20:51:42 1998 David L. Levine * ace/config-linux-pthread.h: added ACE_HAS_THREADS. diff --git a/ace/Signal.cpp b/ace/Signal.cpp index 589e7e953b0..da6929d4b09 100644 --- a/ace/Signal.cpp +++ b/ace/Signal.cpp @@ -183,6 +183,7 @@ void ACE_Sig_Handler::sig_pending (int pending) { ACE_TRACE ("ACE_Sig_Handler::sig_pending"); + ACE_MT (ACE_Recursive_Thread_Mutex *lock = ACE_Managed_Object::get_preallocated_object (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK); @@ -304,14 +305,20 @@ ACE_Sig_Handler::dispatch (int signum, ucontext_t *ucontext) { ACE_TRACE ("ACE_Sig_Handler::dispatch"); + // The following is #ifdef'd out because it's entirely non-portable + // to acquire a mutex in a signal handler... +#if 0 ACE_MT (ACE_Recursive_Thread_Mutex *lock = ACE_Managed_Object::get_preallocated_object (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK); ACE_TSS_Guard m (*lock)); +#endif /* 0 */ // Preserve errno across callbacks! int old_errno = errno; - ACE_Sig_Handler::sig_pending (1); + // We can't use the call here because that acquires + // the lock, which is non-portable... + ACE_Sig_Handler::sig_pending_ = pending; // Darn well better be in range since the OS dispatched this... ACE_ASSERT (ACE_Sig_Handler::in_range (signum)); @@ -651,15 +658,19 @@ ACE_Sig_Handlers::dispatch (int signum, ucontext_t *ucontext) { ACE_TRACE ("ACE_Sig_Handlers::dispatch"); + // The following is #ifdef'd out because it's entirely non-portable + // to acquire a mutex in a signal handler... +#if 0 ACE_MT (ACE_Recursive_Thread_Mutex *lock = ACE_Managed_Object::get_preallocated_object (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK); ACE_TSS_Guard m (*lock)); +#endif /* 0 */ // Preserve errno across callbacks! int old_errno = errno; - ACE_Sig_Handler::sig_pending (1); + ACE_Sig_Handler::sig_pending_ = 1; // Darn well better be in range since the OS dispatched this... ACE_ASSERT (ACE_Sig_Handler::in_range (signum)); -- cgit v1.2.1