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

Paul Jakma paul at clubi.ie
Thu Jul 15 09:45:32 BST 2004


On Wed, 14 Jul 2004, Greg Troxel wrote:

> One possibly useful thing to do is to have a master 'signal handler 
> runnable' flag that gets set by any signal, and have the select 
> loop run the signal handler dispatch when that's set on return from 
> select.  That would make signal handling prompt while keeping the 
> safety properties we have now.

Hmm.. We could create another thread queue i guess, THREAD_SIGNAL or 
somesuch. The natural thing would be to have each thread == signal, 
could remove the statically allocated sigmaster in that case i think. 
but is prompt handling of signals _that_ important? They'll be 
handled within 2s at present, presuming no other threads hog run 
time.

till then, what about below?

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:
Their idea of an offer you can't refuse is an offer... and you'd better
not refuse.

Index: ChangeLog
===================================================================
RCS file: /var/cvsroot/quagga/lib/ChangeLog,v
retrieving revision 1.21
diff -u -r1.21 ChangeLog
--- ChangeLog	13 Jul 2004 13:47:25 -0000	1.21
+++ ChangeLog	15 Jul 2004 08:38:55 -0000
@@ -1,3 +1,11 @@
+2004-07-14 Paul Jakma <paul at dishone.st>
+
+	* sigevent.c: (quagga_signal_handler) add a global caught flag.
+	  (quagga_signal_timer) dont block signals at all.
+	  sig->caught is volatile sig_atomic_t and should be safe to access
+	  from signal and normal contexts. The signal blocking is unneeded
+	  paranoia. Check global caught flag..
+
  2004-07-13  Greg Troxel  <gdt at poblano.ir.bbn.com>

  	* sigevent.c: Don't block SIGTRAP and SIGKILL.  Blocking SIGTRAP
Index: sigevent.c
===================================================================
RCS file: /var/cvsroot/quagga/lib/sigevent.c,v
retrieving revision 1.2
diff -u -r1.2 sigevent.c
--- sigevent.c	13 Jul 2004 13:47:25 -0000	1.2
+++ sigevent.c	15 Jul 2004 08:38:55 -0000
@@ -28,9 +28,10 @@
    struct thread_master *tm;
    struct thread *t;

-  struct quagga_signal_t *signals;
+  struct quagga_signal_t *signals;
    int sigc;
- 
+ 
+  volatile sig_atomic_t caught;
  } sigmaster;

  /* Generic signal handler 
@@ -49,51 +50,37 @@
        if (sig->signal == signo)
          sig->caught++;
      }
+ 
+  sigmaster.caught++;
  }

  int
  quagga_signal_timer (struct thread *t)
  {
-  sigset_t newmask, oldmask;
    struct quagga_sigevent_master_t *sigm;
    struct quagga_signal_t *sig;
    int i;

    sigm = THREAD_ARG (t);
- 
-  /*
-   * Block most signals, but be careful not to defer SIGTRAP because
-   * doing so breaks gdb, at least on NetBSD 2.0.  Avoid asking to
-   * block SIGKILL, just because we shouldn't be able to do so.
-   */
-  sigfillset (&newmask);
-  sigdelset (&newmask, SIGTRAP);
-  sigdelset (&newmask, SIGKILL);

-  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;
-    }
- 
-  for (i = 0; i < sigm->sigc; i++)
+  if (sigm->caught > 0)
      {
-      sig = &(sigm->signals[i]);
-      if (sig->caught > 0)
+      sigm->caught = 0;
+ 
+      for (i = 0; i < sigm->sigc; i++)
          {
-          sig->caught = 0;
-          sig->handler();
+          sig = &(sigm->signals[i]);
+
+          if (sig->caught > 0)
+            {
+              sig->caught = 0;
+              sig->handler ();
+            }
          }
      }
- 
-  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