1
0
mirror of https://github.com/fluencelabs/musl synced 2025-07-27 20:31:58 +00:00

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.
This commit is contained in:
Rich Felker
2013-09-02 15:16:36 -04:00
parent a731e4103b
commit 3c0501d28c

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