summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-10-01 07:22:55 (GMT)
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-10-01 08:38:36 (GMT)
commit2db081b5ffb07a2e6bdac58122fa3466830b12a9 (patch)
tree73fdf73ed1232ab71bd9244da1df72eced2257f7 /thread.c
parent1d3024da26b2d1c48a04864024a5ed51a8ba3139 (diff)
Don't use `th->scheduler` directly because it's not always valid to do so.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3613
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/thread.c b/thread.c
index 81172dc..6cc0a92 100644
--- a/thread.c
+++ b/thread.c
@@ -1175,8 +1175,10 @@ thread_join_sleep(VALUE arg)
}
while (target_th->status != THREAD_KILLED) {
- if (th->scheduler != Qnil) {
- rb_scheduler_block(th->scheduler, target_th->self, p->timeout);
+ VALUE scheduler = rb_thread_current_scheduler();
+
+ if (scheduler != Qnil) {
+ rb_scheduler_block(scheduler, target_th->self, p->timeout);
} else if (!limit) {
th->status = THREAD_STOPPED_FOREVER;
rb_ractor_sleeper_threads_inc(th->ractor);