зеркало из https://github.com/github/ruby.git
process.c: fix potential missed wakeups in r64576
Oddly, all existing test cases passed multiple times before this patch (even with --jit-wait), so this seems like a difficult failure to prove. Fixes: r64576 ("process.c: simplify SIGCHLD-based waitpid") git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
9d4027b503
Коммит
e61e6ae587
37
process.c
37
process.c
|
@ -936,21 +936,19 @@ void rb_sigwait_fd_put(const rb_thread_t *, int fd);
|
|||
void rb_thread_sleep_interruptible(void);
|
||||
|
||||
static int
|
||||
sigwait_fd_migrate_signaled_p(struct waitpid_state *w)
|
||||
waitpid_signal(struct waitpid_state *w)
|
||||
{
|
||||
int signaled = FALSE;
|
||||
rb_thread_t *th = w->ec ? rb_ec_thread_ptr(w->ec) : 0;
|
||||
|
||||
if (th) rb_native_mutex_lock(&th->interrupt_lock);
|
||||
|
||||
if (w->cond) {
|
||||
rb_native_cond_signal(w->cond);
|
||||
signaled = TRUE;
|
||||
if (w->ec) { /* rb_waitpid */
|
||||
rb_threadptr_interrupt(rb_ec_thread_ptr(w->ec));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (th) rb_native_mutex_unlock(&th->interrupt_lock);
|
||||
|
||||
return signaled;
|
||||
else { /* ruby_waitpid_locked */
|
||||
if (w->cond) {
|
||||
rb_native_cond_signal(w->cond);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -964,10 +962,10 @@ sigwait_fd_migrate_sleeper(rb_vm_t *vm)
|
|||
struct waitpid_state *w = 0;
|
||||
|
||||
list_for_each(&vm->waiting_pids, w, wnode) {
|
||||
if (sigwait_fd_migrate_signaled_p(w)) return;
|
||||
if (waitpid_signal(w)) return;
|
||||
}
|
||||
list_for_each(&vm->waiting_grps, w, wnode) {
|
||||
if (sigwait_fd_migrate_signaled_p(w)) return;
|
||||
if (waitpid_signal(w)) return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -995,14 +993,7 @@ waitpid_each(struct list_head *head)
|
|||
|
||||
w->ret = ret;
|
||||
list_del_init(&w->wnode);
|
||||
if (w->ec) { /* rb_waitpid */
|
||||
rb_threadptr_interrupt(rb_ec_thread_ptr(w->ec));
|
||||
}
|
||||
else { /* ruby_waitpid_locked */
|
||||
if (w->cond) {
|
||||
rb_native_cond_signal(w->cond);
|
||||
}
|
||||
}
|
||||
waitpid_signal(w);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
|
Загрузка…
Ссылка в новой задаче