瀏覽代碼

in synccall, ignore the signal before any threads' signal handlers return

this protects against deadlock from spurious signals (e.g. sent by
another process) arriving after the controlling thread releases the
other threads from the sync operation.
Rich Felker 11 年之前
父節點
當前提交
3c0501d28c
共有 1 個文件被更改,包括 4 次插入4 次删除
  1. 4 4
      src/thread/synccall.c

+ 4 - 4
src/thread/synccall.c

@@ -71,6 +71,10 @@ void __synccall(void (*func)(void *), void *ctx)
 	sigqueue(self->pid, SIGSYNCCALL, (union sigval){0});
 	while (sem_wait(&chaindone));
 
+	sa.sa_flags = 0;
+	sa.sa_handler = SIG_IGN;
+	__libc_sigaction(SIGSYNCCALL, &sa, 0);
+
 	for (cur=head; cur; cur=cur->next) {
 		sem_post(&cur->sem);
 		while (sem_wait(&cur->sem2));
@@ -82,10 +86,6 @@ void __synccall(void (*func)(void *), void *ctx)
 		sem_post(&cur->sem);
 	}
 
-	sa.sa_flags = 0;
-	sa.sa_handler = SIG_IGN;
-	__libc_sigaction(SIGSYNCCALL, &sa, 0);
-
 	__syscall(SYS_rt_sigprocmask, SIG_SETMASK,
 		&oldmask, 0, _NSIG/8);