ruby-changes:51578
From: normal <ko1@a...>
Date: Fri, 29 Jun 2018 19:41:19 +0900 (JST)
Subject: [ruby-changes:51578] normal:r63789 (trunk): process.c (waitpid_nogvl): check interrupts before sleeping
normal 2018-06-29 16:52:24 +0900 (Fri, 29 Jun 2018) New Revision: 63789 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63789 Log: 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 Modified files: trunk/process.c Index: process.c =================================================================== --- process.c (revision 63788) +++ process.c (revision 63789) @@ -1017,7 +1017,11 @@ waitpid_nogvl(void *x) https://github.com/ruby/ruby/blob/trunk/process.c#L1017 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); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/