summaryrefslogtreecommitdiff
path: root/thread_sync.c
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2020-09-18 10:39:27 +0200
committerBenoit Daloze <eregontp@gmail.com>2020-09-18 10:39:27 +0200
commit5bb5e706f1d310a467075630145d2cc277045765 (patch)
treec15fb07d222de8a3ea271542345e2984c66e664b /thread_sync.c
parent305c4306032c4713f99e668d460bc1bbd53f39bf (diff)
Only interrupt when there is no scheduler in sync_wakeup()
* When there is a scheduler, the Fiber that would be blocked has already been rescheduled and there is no point to interrupt something else. That blocked Fiber will be rescheduled as the next call to the scheduler (e.g., IO, sleep, other blocking sync). * See discussion on https://github.com/ruby/ruby/commit/d01954632d
Diffstat (limited to 'thread_sync.c')
-rw-r--r--thread_sync.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/thread_sync.c b/thread_sync.c
index 41df2dead9..748ccbd558 100644
--- a/thread_sync.c
+++ b/thread_sync.c
@@ -34,8 +34,10 @@ sync_wakeup(struct list_head *head, long max)
}
if (cur->th->status != THREAD_KILLED) {
- rb_threadptr_interrupt(cur->th);
- cur->th->status = THREAD_RUNNABLE;
+ if (cur->th->scheduler != Qnil) {
+ rb_threadptr_interrupt(cur->th);
+ cur->th->status = THREAD_RUNNABLE;
+ }
if (--max == 0) return;
}
}