From 5bb5e706f1d310a467075630145d2cc277045765 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Fri, 18 Sep 2020 10:39:27 +0200 Subject: 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 --- thread_sync.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'thread_sync.c') 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; } } -- cgit v1.2.3