From adbd6ee028c873423cef93372c381dae9f72fbbd Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Thu, 20 Jan 2000 04:46:52 +0000 Subject: [PATCH] Do signal deferral for pthread_kill() as it was done in the old days. Submitted by: deischen --- lib/libc_r/uthread/pthread_private.h | 5 ----- lib/libc_r/uthread/uthread_kern.c | 8 +++----- lib/libc_r/uthread/uthread_sig.c | 23 +++-------------------- lib/libkse/thread/thr_kern.c | 8 +++----- lib/libkse/thread/thr_private.h | 5 ----- lib/libkse/thread/thr_sig.c | 23 +++-------------------- lib/libpthread/thread/thr_kern.c | 8 +++----- lib/libpthread/thread/thr_private.h | 5 ----- lib/libpthread/thread/thr_sig.c | 23 +++-------------------- 9 files changed, 18 insertions(+), 90 deletions(-) diff --git a/lib/libc_r/uthread/pthread_private.h b/lib/libc_r/uthread/pthread_private.h index 8bc2d3fbcae..560ea44d614 100644 --- a/lib/libc_r/uthread/pthread_private.h +++ b/lib/libc_r/uthread/pthread_private.h @@ -572,11 +572,6 @@ struct pthread { sigset_t sigmask; sigset_t sigpend; -#ifndef _NO_UNDISPATCH - /* Non-zero if there are undispatched signals for this thread. */ - int undispatched_signals; -#endif - /* Thread state: */ enum pthread_state state; enum pthread_state oldstate; diff --git a/lib/libc_r/uthread/uthread_kern.c b/lib/libc_r/uthread/uthread_kern.c index b83306157fc..3e0ff17435d 100644 --- a/lib/libc_r/uthread/uthread_kern.c +++ b/lib/libc_r/uthread/uthread_kern.c @@ -39,7 +39,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -122,16 +124,12 @@ __asm__("fnsave %0": :"m"(*fdata)); pthread_testcancel(); } -#ifndef _NO_UNDISPATCH /* * Check for undispatched signals due to calls to * pthread_kill(). */ - if (_thread_run->undispatched_signals != 0) { - _thread_run->undispatched_signals = 0; + if (SIGNOTEMPTY(_thread_run->sigpend)) _dispatch_signals(); - } -#endif if (_sched_switch_hook != NULL) { /* Run the installed switch hook: */ diff --git a/lib/libc_r/uthread/uthread_sig.c b/lib/libc_r/uthread/uthread_sig.c index 0f18477d0e9..dc6d209f85b 100644 --- a/lib/libc_r/uthread/uthread_sig.c +++ b/lib/libc_r/uthread/uthread_sig.c @@ -628,27 +628,10 @@ _thread_sig_send(pthread_t pthread, int sig) !sigismember(&pthread->sigmask, sig)) { /* Perform any state changes due to signal arrival: */ thread_sig_check_state(pthread, sig); - -#ifndef _NO_UNDISPATCH - if (_thread_run != pthread) { - /* - * Make a note to call the signal handler once - * the signaled thread is running. This is - * necessary in order to make sure that the - * signal is delivered on the correct stack. - */ - pthread->undispatched_signals++; - } else { -#endif - /* Call the installed signal handler. */ - _thread_sig_deliver(pthread, sig); -#ifndef _NO_UNDISPATCH - } -#endif - } else { - /* Increment the pending signal count. */ - sigaddset(&pthread->sigpend,sig); } + + /* Increment the pending signal count. */ + sigaddset(&pthread->sigpend,sig); } } diff --git a/lib/libkse/thread/thr_kern.c b/lib/libkse/thread/thr_kern.c index b83306157fc..3e0ff17435d 100644 --- a/lib/libkse/thread/thr_kern.c +++ b/lib/libkse/thread/thr_kern.c @@ -39,7 +39,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -122,16 +124,12 @@ __asm__("fnsave %0": :"m"(*fdata)); pthread_testcancel(); } -#ifndef _NO_UNDISPATCH /* * Check for undispatched signals due to calls to * pthread_kill(). */ - if (_thread_run->undispatched_signals != 0) { - _thread_run->undispatched_signals = 0; + if (SIGNOTEMPTY(_thread_run->sigpend)) _dispatch_signals(); - } -#endif if (_sched_switch_hook != NULL) { /* Run the installed switch hook: */ diff --git a/lib/libkse/thread/thr_private.h b/lib/libkse/thread/thr_private.h index 8bc2d3fbcae..560ea44d614 100644 --- a/lib/libkse/thread/thr_private.h +++ b/lib/libkse/thread/thr_private.h @@ -572,11 +572,6 @@ struct pthread { sigset_t sigmask; sigset_t sigpend; -#ifndef _NO_UNDISPATCH - /* Non-zero if there are undispatched signals for this thread. */ - int undispatched_signals; -#endif - /* Thread state: */ enum pthread_state state; enum pthread_state oldstate; diff --git a/lib/libkse/thread/thr_sig.c b/lib/libkse/thread/thr_sig.c index 0f18477d0e9..dc6d209f85b 100644 --- a/lib/libkse/thread/thr_sig.c +++ b/lib/libkse/thread/thr_sig.c @@ -628,27 +628,10 @@ _thread_sig_send(pthread_t pthread, int sig) !sigismember(&pthread->sigmask, sig)) { /* Perform any state changes due to signal arrival: */ thread_sig_check_state(pthread, sig); - -#ifndef _NO_UNDISPATCH - if (_thread_run != pthread) { - /* - * Make a note to call the signal handler once - * the signaled thread is running. This is - * necessary in order to make sure that the - * signal is delivered on the correct stack. - */ - pthread->undispatched_signals++; - } else { -#endif - /* Call the installed signal handler. */ - _thread_sig_deliver(pthread, sig); -#ifndef _NO_UNDISPATCH - } -#endif - } else { - /* Increment the pending signal count. */ - sigaddset(&pthread->sigpend,sig); } + + /* Increment the pending signal count. */ + sigaddset(&pthread->sigpend,sig); } } diff --git a/lib/libpthread/thread/thr_kern.c b/lib/libpthread/thread/thr_kern.c index b83306157fc..3e0ff17435d 100644 --- a/lib/libpthread/thread/thr_kern.c +++ b/lib/libpthread/thread/thr_kern.c @@ -39,7 +39,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -122,16 +124,12 @@ __asm__("fnsave %0": :"m"(*fdata)); pthread_testcancel(); } -#ifndef _NO_UNDISPATCH /* * Check for undispatched signals due to calls to * pthread_kill(). */ - if (_thread_run->undispatched_signals != 0) { - _thread_run->undispatched_signals = 0; + if (SIGNOTEMPTY(_thread_run->sigpend)) _dispatch_signals(); - } -#endif if (_sched_switch_hook != NULL) { /* Run the installed switch hook: */ diff --git a/lib/libpthread/thread/thr_private.h b/lib/libpthread/thread/thr_private.h index 8bc2d3fbcae..560ea44d614 100644 --- a/lib/libpthread/thread/thr_private.h +++ b/lib/libpthread/thread/thr_private.h @@ -572,11 +572,6 @@ struct pthread { sigset_t sigmask; sigset_t sigpend; -#ifndef _NO_UNDISPATCH - /* Non-zero if there are undispatched signals for this thread. */ - int undispatched_signals; -#endif - /* Thread state: */ enum pthread_state state; enum pthread_state oldstate; diff --git a/lib/libpthread/thread/thr_sig.c b/lib/libpthread/thread/thr_sig.c index 0f18477d0e9..dc6d209f85b 100644 --- a/lib/libpthread/thread/thr_sig.c +++ b/lib/libpthread/thread/thr_sig.c @@ -628,27 +628,10 @@ _thread_sig_send(pthread_t pthread, int sig) !sigismember(&pthread->sigmask, sig)) { /* Perform any state changes due to signal arrival: */ thread_sig_check_state(pthread, sig); - -#ifndef _NO_UNDISPATCH - if (_thread_run != pthread) { - /* - * Make a note to call the signal handler once - * the signaled thread is running. This is - * necessary in order to make sure that the - * signal is delivered on the correct stack. - */ - pthread->undispatched_signals++; - } else { -#endif - /* Call the installed signal handler. */ - _thread_sig_deliver(pthread, sig); -#ifndef _NO_UNDISPATCH - } -#endif - } else { - /* Increment the pending signal count. */ - sigaddset(&pthread->sigpend,sig); } + + /* Increment the pending signal count. */ + sigaddset(&pthread->sigpend,sig); } }