]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE12-pthread-fileserver-create-signal-thread-20030103
authorNickolai Zeldovich <kolya@mit.edu>
Fri, 31 Jan 2003 21:05:18 +0000 (21:05 +0000)
committerGarry Zacheiss <zacheiss@mit.edu>
Fri, 31 Jan 2003 21:05:18 +0000 (21:05 +0000)
Create a special thread to receive signals in the pthread fileserver, in
order to avoid deadlock (we have signal handlers that unsafely grab locks).

(cherry picked from commit d86a3e307ec8ef4d35d8a9b96f3a5db1fbc5cd86)

src/viced/viced.c

index 09ef38251c5ecb5443421c26f116d5766a3f5bb7..033186a62af44cd87e3e1e1163ea079bd43cb7e3 100644 (file)
@@ -299,7 +299,7 @@ main(argc, argv)
 #ifdef AFS_PTHREAD_ENV
     pthread_t parentPid, serverPid;
     pthread_attr_t tattr;
-    AFS_SIGSET_DECL;
+    sigset_t nsigset;
 #else /* AFS_PTHREAD_ENV */
     PROCESS parentPid, serverPid;
 #endif /* AFS_PTHREAD_ENV */
@@ -571,8 +571,11 @@ main(argc, argv)
 #ifdef AFS_PTHREAD_ENV
     assert(pthread_attr_init(&tattr) == 0);
     assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0);
-    /* Block signals in the threads */
-    AFS_SIGSET_CLEAR();
+    /* Block signals in this thread (and children), create a signal thread */
+    sigfillset(&nsigset);
+    assert(AFS_SET_SIGMASK(SIG_BLOCK, &nsigset, NULL) == 0);
+    assert(pthread_create(&serverPid, &tattr, (void *)SignalLWP, NULL) == 0);
+
     assert(pthread_create(&serverPid, &tattr, (void *)FiveMinuteCheckLWP, &fiveminutes) == 0);
     assert(pthread_create(&serverPid, &tattr, (void *)HostCheckLWP, &fiveminutes) == 0);
     AFS_SIGSET_RESTORE();
@@ -647,6 +650,21 @@ static void setThreadId(char *s)
 #endif
 }
 
+#ifdef AFS_PTHREAD_ENV
+/* A special LWP that will receive signals, to avoid deadlock */
+static void SignalLWP()
+{
+    sigset_t nsigset;
+
+    sigfillset(&nsigset);
+    assert(AFS_SET_SIGMASK(SIG_UNBLOCK, &nsigset, NULL) == 0);
+
+    while (1)
+       sleep(60);
+}
+#endif
+
+
 /* This LWP does things roughly every 5 minutes */
 static FiveMinuteCheckLWP()