From 587d2d199b3f783d03266d42d066949f8a4824d3 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 7 Jul 2022 15:20:35 +0200 Subject: thread_pthread.c: call SUSPENDED event when entering native_sleep [Bug #18900] Thread#join and a few other codepaths are using native sleep as a way to suspend the current thread. So we should call the relevant hook when this happen, otherwise some thread may transition directly from `RESUMED` to `READY`. --- thread_pthread.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'thread_pthread.c') diff --git a/thread_pthread.c b/thread_pthread.c index 02a3640bdb..8597479765 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -2337,6 +2337,8 @@ native_sleep(rb_thread_t *th, rb_hrtime_t *rel) int sigwait_fd = rb_sigwait_fd_get(th); rb_ractor_blocking_threads_inc(th->ractor, __FILE__, __LINE__); + RB_INTERNAL_THREAD_HOOK(RUBY_INTERNAL_THREAD_EVENT_SUSPENDED); + if (sigwait_fd >= 0) { rb_native_mutex_lock(&th->interrupt_lock); th->unblock.func = ubf_sigwait; -- cgit v1.2.1