[or-cvs] r9603: Apply patch from coderman: have posix subthreads mask out si (in tor/trunk: . src/common)

nickm at seul.org nickm at seul.org
Tue Feb 20 18:34:19 UTC 2007


Author: nickm
Date: 2007-02-20 13:34:18 -0500 (Tue, 20 Feb 2007)
New Revision: 9603

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/common/compat.c
Log:
 r11850 at catbus:  nickm | 2007-02-20 13:34:13 -0500
 Apply patch from coderman: have posix subthreads mask out signals.  This could prevent some kinds of crashes when subthreads try to handle SIGPIPEs and die in the attempt.  Backport candidate.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11850] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-02-19 14:53:56 UTC (rev 9602)
+++ tor/trunk/ChangeLog	2007-02-20 18:34:18 UTC (rev 9603)
@@ -39,6 +39,9 @@
     - When EntryNodes are configured, rebuild the guard list to contain, in
       order: the EntryNodes that were guards before; the rest of the
       EntryNodes; the nodes that were guards before.
+    - Mask out all signals in sub-threads; only the libevent signal handler
+      should be processing them. This should prevent some crashes on some
+      machines using pthreads. (Patch from coderman.)
 
   o Minor features (controller):
     - Warn the user when an application uses the obsolete binary v0

Modified: tor/trunk/src/common/compat.c
===================================================================
--- tor/trunk/src/common/compat.c	2007-02-19 14:53:56 UTC (rev 9602)
+++ tor/trunk/src/common/compat.c	2007-02-20 18:34:18 UTC (rev 9603)
@@ -82,6 +82,9 @@
 #ifdef HAVE_PTHREAD_H
 #include <pthread.h>
 #endif
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
 #ifdef HAVE_UTIME_H
 #include <utime.h>
 #endif
@@ -996,6 +999,12 @@
   tor_pthread_data_t *data = _data;
   void (*func)(void*);
   void *arg;
+  /* mask signals to worker threads to avoid SIGPIPE, etc */
+  sigset_t sigs;
+  /* We're in a subthread; don't handle any signals here. */
+  sigfillset(&sigs);
+  pthread_sigmask(SIG_SETMASK, &sigs, NULL);
+
   func = data->func;
   arg = data->data;
   tor_free(_data);



More information about the tor-commits mailing list