From dc3dc49831af710f58f4e63f672ccd1d4bab83af Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 1 Aug 2011 00:02:04 +0000 Subject: [PATCH] * sigproc.cc (pending_signals::pending): Define new function. (sig_dispatch_pending): Avoid calling sig_send if there are no pending signals. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/sigproc.cc | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index cc62bc20c..569f35960 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2011-07-31 Christopher Faylor + + * sigproc.cc (pending_signals::pending): Define new function. + (sig_dispatch_pending): Avoid calling sig_send if there are no pending + signals. + 2011-07-31 Corinna Vinschen * fhandler.h (class fhandler_dev_mem): Remove dup method declaration. diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 8e458b9bf..fcd559b38 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -88,6 +88,7 @@ public: void reset () {curr = &start; prev = &start;} void add (sigpacket&); void del (); + bool pending () const {return !!start.next;} sigpacket *next (); sigpacket *save () const {return curr;} void restore (sigpacket *saved) {curr = saved;} @@ -431,7 +432,13 @@ sig_dispatch_pending (bool fast) return; } - sig_send (myself, fast ? __SIGFLUSHFAST : __SIGFLUSH); + /* Non-atomically test for any signals pending and wake up wait_sig if any are + found. It's ok if there's a race here since the next call to this function + should catch it. + FIXME: Eventually, wait_sig should wake up on its own to deal with pending + signals. */ + if (sigq.pending ()) + sig_send (myself, fast ? __SIGFLUSHFAST : __SIGFLUSH); } void __stdcall