This is the mail archive of the cygwin-cvs@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[newlib-cygwin] Fix incorrect implementation to clear per-thread pending signals


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=90b9303f0b43de0568606677cda779e781464a00

commit 90b9303f0b43de0568606677cda779e781464a00
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Mon Nov 2 13:53:25 2015 +0100

    Fix incorrect implementation to clear per-thread pending signals
    
    	* sigproc.cc (class pending_signals): Drop sigproc_init friendship.
    	(pending_signals::clear): Fix implementation to avoid subsequent
    	endless loop in wait_sig.  Improve comment.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/ChangeLog  |  6 ++++++
 winsup/cygwin/sigproc.cc | 16 +++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 9dfa1b3..179eb24 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,11 @@
 2015-11-02  Corinna Vinschen  <corinna@vinschen.de>
 
+	* sigproc.cc (class pending_signals): Drop sigproc_init friendship.
+	(pending_signals::clear): Fix implementation to avoid subsequent
+	endless loop in wait_sig.  Improve comment.
+
+2015-11-02  Corinna Vinschen  <corinna@vinschen.de>
+
 	* mount.h (enum fs_info_type): Add prlfs (Parallels Desktop FS).
 	(class fs_info): Add has_broken_fnoi flag.  Implement prlfs FS flag.
 	* mount.cc (fs_info::update): Handle PrlFS.  Fill new has_broken_fnoi
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 387a71a..fbc738d 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -82,7 +82,6 @@ public:
   void clear (_cygtls *tls);
   friend void __reg1 sig_dispatch_pending (bool);
   friend void WINAPI wait_sig (VOID *arg);
-  friend void sigproc_init ();
 };
 
 Static pending_signals sigq;
@@ -398,14 +397,21 @@ sig_clear (int sig)
   sigq.clear (sig);
 }
 
-/* Clear pending signals of specific thread.  Called from
+/* Clear pending signals of specific thread.  Called under TLS lock from
    _cygtls::remove_pending_sigs. */
 void
 pending_signals::clear (_cygtls *tls)
 {
-  for (int sig = 0; sig < NSIG + 1; ++sig)
-    if (sigs[sig].sigtls == tls)
-      clear (sig);
+  sigpacket *q = &start, *qnext;
+
+  while ((qnext = q->next))
+    {
+      if (qnext->sigtls == tls)
+	{
+	  q->next = qnext->next;
+	  qnext->si.si_signo = 0;
+	}
+    }
 }
 
 /* Clear pending signals of specific thread.  Called from _cygtls::remove */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]