aboutsummaryrefslogtreecommitdiffstats
path: root/process.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-29 07:52:24 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-29 07:52:24 +0000
commitee0619dbb3889cfaeaec886954f7cf7765c5c14f (patch)
treee7fc191080add11028c0753e8c4cf7e7a988b3de /process.c
parentaf927eda968d4a44b82bc9d813a618adb17720ba (diff)
downloadruby-ee0619dbb3889cfaeaec886954f7cf7765c5c14f.tar.gz
process.c (waitpid_nogvl): check interrupts before sleeping
We may be interrupted by another thread after setting ubf, but before we re-acquire interrupt_lock again to sleep on w->cond. This should fix test_wait_interrupt in test/ruby/test_process.rb git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/process.c b/process.c
index b3932e88ce..4388a6ba0f 100644
--- a/process.c
+++ b/process.c
@@ -1017,7 +1017,11 @@ waitpid_nogvl(void *x)
rb_thread_t *th = rb_ec_thread_ptr(w->ec);
rb_native_mutex_lock(&th->interrupt_lock);
- if (!w->ret) { /* we must check this before waiting */
+ /*
+ * We must check again before waiting, timer-thread may change w->ret
+ * by the time we enter this. And we may also be interrupted.
+ */
+ if (!w->ret && !RUBY_VM_INTERRUPTED_ANY(w->ec)) {
rb_native_cond_wait(w->cond, &th->interrupt_lock);
}
rb_native_mutex_unlock(&th->interrupt_lock);