Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpthread Keep the kernel updated with signal action si...



details:   https://anonhg.NetBSD.org/src/rev/f5e7e8b5cf49
branches:  trunk
changeset: 574326:f5e7e8b5cf49
user:      nathanw <nathanw%NetBSD.org@localhost>
date:      Sat Feb 26 20:33:06 2005 +0000

description:
Keep the kernel updated with signal action signal masks (act.sa_mask) until
threads are started, since before that the traditional signal invocation
method will be used. Fixes regress/lib/libpthread/sigmask2.

diffstat:

 lib/libpthread/pthread.c     |   6 ++++--
 lib/libpthread/pthread_int.h |   3 ++-
 lib/libpthread/pthread_sig.c |  26 +++++++++++++++++++++-----
 3 files changed, 27 insertions(+), 8 deletions(-)

diffs (98 lines):

diff -r 00fccbb28853 -r f5e7e8b5cf49 lib/libpthread/pthread.c
--- a/lib/libpthread/pthread.c  Sat Feb 26 20:12:58 2005 +0000
+++ b/lib/libpthread/pthread.c  Sat Feb 26 20:33:06 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread.c,v 1.40 2005/02/10 23:42:37 christos Exp $    */
+/*     $NetBSD: pthread.c,v 1.41 2005/02/26 20:33:06 nathanw Exp $     */
 
 /*-
  * Copyright (c) 2001,2002,2003 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread.c,v 1.40 2005/02/10 23:42:37 christos Exp $");
+__RCSID("$NetBSD: pthread.c,v 1.41 2005/02/26 20:33:06 nathanw Exp $");
 
 #include <err.h>
 #include <errno.h>
@@ -252,6 +252,8 @@
         */
        pthread__alarm_init();
 
+       pthread__signal_start();
+
        pthread_atfork(NULL, NULL, pthread__child_callback);
 
        /*
diff -r 00fccbb28853 -r f5e7e8b5cf49 lib/libpthread/pthread_int.h
--- a/lib/libpthread/pthread_int.h      Sat Feb 26 20:12:58 2005 +0000
+++ b/lib/libpthread/pthread_int.h      Sat Feb 26 20:33:06 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_int.h,v 1.30 2004/10/12 22:17:56 mycroft Exp $ */
+/*     $NetBSD: pthread_int.h,v 1.31 2005/02/26 20:33:06 nathanw Exp $ */
 
 /*-
  * Copyright (c) 2001,2002,2003 The NetBSD Foundation, Inc.
@@ -362,6 +362,7 @@
     pthread_spin_t *lock);
 
 void   pthread__signal_init(void);
+void   pthread__signal_start(void);
 
 void   pthread__signal(pthread_t self, pthread_t t, siginfo_t *si);
 void   pthread__deliver_signal(pthread_t self, pthread_t t, siginfo_t *si);
diff -r 00fccbb28853 -r f5e7e8b5cf49 lib/libpthread/pthread_sig.c
--- a/lib/libpthread/pthread_sig.c      Sat Feb 26 20:12:58 2005 +0000
+++ b/lib/libpthread/pthread_sig.c      Sat Feb 26 20:33:06 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_sig.c,v 1.37 2005/02/26 18:15:25 nathanw Exp $ */
+/*     $NetBSD: pthread_sig.c,v 1.38 2005/02/26 20:33:06 nathanw Exp $ */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_sig.c,v 1.37 2005/02/26 18:15:25 nathanw Exp $");
+__RCSID("$NetBSD: pthread_sig.c,v 1.38 2005/02/26 20:33:06 nathanw Exp $");
 
 /* We're interposing a specific version of the signal interface. */
 #define        __LIBC12_SOURCE__
@@ -127,6 +127,20 @@
        PTQ_INIT(&pt_sigwaiting);
 }
 
+void
+pthread__signal_start(void)
+{
+       int i;
+       struct sigaction act;
+
+       /* Clear all additional signal masks; we'll handle them ourselves */
+       for (i = 1 ; i < NSIG ; i++) {
+               __libc_sigaction14(i, NULL, &act);
+               __sigemptyset14(&act.sa_mask);
+               __libc_sigaction14(i, &act, NULL);
+       }
+}
+
 static void
 pthread__make_siginfo(siginfo_t *si, int sig)
 {
@@ -215,9 +229,11 @@
                 * appropriate, because that would permit a continuous
                 * stream of signals to exhaust the supply of upcalls.
                 */
-               realact = *act;
-               __sigemptyset14(&realact.sa_mask);
-               act = &realact;
+               if (pthread__started) {
+                       realact = *act;
+                       __sigemptyset14(&realact.sa_mask);
+                       act = &realact;
+               }
        } else
                pthread_spinunlock(self, &pt_sigacts_lock);
 



Home | Main Index | Thread Index | Old Index