1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
Benoit Daloze 2020-09-18 10:39:27 +02:00
parent 305c430603
commit 5bb5e706f1

View file

@ -34,8 +34,10 @@ sync_wakeup(struct list_head *head, long max)
} }
if (cur->th->status != THREAD_KILLED) { if (cur->th->status != THREAD_KILLED) {
rb_threadptr_interrupt(cur->th); if (cur->th->scheduler != Qnil) {
cur->th->status = THREAD_RUNNABLE; rb_threadptr_interrupt(cur->th);
cur->th->status = THREAD_RUNNABLE;
}
if (--max == 0) return; if (--max == 0) return;
} }
} }