[quagga-dev 1355] Re: signal handling breaks gdb on NetBSD - fixed in CVS

Paul Jakma paul at clubi.ie
Wed Jul 14 12:52:57 BST 2004


On Wed, 14 Jul 2004, Paul Jakma wrote:

> If they are not atomic, the other possibility is to only block the specific 
> signal concerned, and only block the comparison and the increment. However, 
> that seems like a lot of overhead.

Eg, something like the below, compiles-but-not-tested, patch. Though, 
we can just strip the signal blocking altogether if someone knows for 
sure whether sig_atomic_t can be counted on to be atomic as its 
name suggests. :)

regards,
-- 
Paul Jakma	paul at clubi.ie	paul at jakma.org	Key ID: 64A2FF6A
 	warning: do not ever send email to spam at dishone.st
Fortune:
Demand the establishment of the government in its rightful home at Disneyland.

Index: sigevent.c
===================================================================
RCS file: /var/cvsroot/quagga/lib/sigevent.c,v
retrieving revision 1.1
diff -u -r1.1 sigevent.c
--- sigevent.c	19 Jan 2004 21:23:37 -0000	1.1
+++ sigevent.c	14 Jul 2004 11:52:29 -0000
@@ -54,39 +54,50 @@
  int
  quagga_signal_timer (struct thread *t)
  {
-  sigset_t newmask, oldmask;
+  sigset_t sset;
    struct quagga_sigevent_master_t *sigm;
    struct quagga_signal_t *sig;
    int i;

    sigm = THREAD_ARG (t);
- 
-  /* block all signals */
-  sigfillset (&newmask);
-  if ( (sigprocmask (SIG_BLOCK, &newmask, &oldmask)) < 0)
-    {
-      zlog_err ("quagga_signal_timer: couldnt block signals!");
-		  sigm->t = thread_add_timer (sigm->tm, quagga_signal_timer, 
-		                              &sigmaster, QUAGGA_SIGNAL_TIMER_INTERVAL); 
-      return -1;
-    }
- 
+
+  sigemptyset (&sset);
+
    for (i = 0; i < sigm->sigc; i++)
      {
        sig = &(sigm->signals[i]);
+
+      sigaddset (&sset, sig->signal);
+
+      if ((sigprocmask (SIG_BLOCK, &sset, NULL)) < 0)
+        {
+          zlog_err ("quagga_signal_timer: couldnt block signal %d!",
+                    sig->signal);
+          sigm->t = thread_add_timer (sigm->tm, quagga_signal_timer,
+                                      &sigmaster,
+                                      QUAGGA_SIGNAL_TIMER_INTERVAL);
+          return -1;
+        }
+
+      sigdelset (&sset, sig->signal);
+
        if (sig->caught > 0)
          {
            sig->caught = 0;
-          sig->handler();
+
+          if (sigprocmask (SIG_UNBLOCK, &sset, NULL) < 0)
+            zlog_err ("quagga_signal_timer: couldnt unblock signal %d!",
+                      sig->signal);
+
+          sig->handler ();
          }
+      else if (sigprocmask (SIG_UNBLOCK, &sset, NULL) < 0)
+        zlog_err ("quagga_signal_timer: couldnt unblock signal %d!",
+                  sig->signal);
      }
- 
-  sigm->t = thread_add_timer (sigm->tm, quagga_signal_timer, &sigmaster, 
-                                           QUAGGA_SIGNAL_TIMER_INTERVAL);
-
-  if ( sigprocmask (SIG_UNBLOCK, &oldmask, NULL) < 0 );
-    return -1;
- 
+
+  sigm->t = thread_add_timer (sigm->tm, quagga_signal_timer, &sigmaster,
+                              QUAGGA_SIGNAL_TIMER_INTERVAL);
    return 0;
  }




More information about the Quagga-dev mailing list