mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
process.c (waitpid_nogvl): prevent conflicting use of sleep_cond
We reuse sleep_cond for waitpid notifications as well as GVL waiting. So we must take care to not hold onto sleep_cond when we try to reacquire GVL. [ruby-core:88183] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
56491afc79
commit
7018acc946
1 changed files with 17 additions and 1 deletions
16
process.c
16
process.c
|
@ -1144,6 +1144,9 @@ waitpid_nogvl(void *x)
|
|||
rb_sigwait_fd_put(th, sigwait_fd);
|
||||
}
|
||||
else {
|
||||
if (!w->cond)
|
||||
w->cond = rb_sleep_cond_get(w->ec);
|
||||
|
||||
/* another thread calling rb_sigwait_sleep will process
|
||||
* signals for us */
|
||||
if (SIGCHLD_LOSSY) {
|
||||
|
@ -1152,6 +1155,16 @@ waitpid_nogvl(void *x)
|
|||
rb_native_cond_wait(w->cond, &th->interrupt_lock);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* we must release th->native_thread_data.sleep_cond when
|
||||
* re-acquiring GVL:
|
||||
*/
|
||||
if (w->cond) {
|
||||
rb_sleep_cond_put(w->cond);
|
||||
w->cond = 0;
|
||||
}
|
||||
|
||||
rb_native_mutex_unlock(&th->interrupt_lock);
|
||||
|
||||
if (sigwait_fd >= 0)
|
||||
|
@ -1183,6 +1196,9 @@ waitpid_cleanup(VALUE x)
|
|||
list_del(&w->wnode);
|
||||
rb_native_mutex_unlock(&vm->waitpid_lock);
|
||||
}
|
||||
|
||||
/* we may have never released and re-acquired GVL */
|
||||
if (w->cond)
|
||||
rb_sleep_cond_put(w->cond);
|
||||
|
||||
return Qfalse;
|
||||
|
|
Loading…
Reference in a new issue