From 2e420b8b99db4a5b81e2deda1ca386d59ad6bcba Mon Sep 17 00:00:00 2001 From: normal Date: Sat, 18 Aug 2018 20:04:07 +0000 Subject: thread_sync.c (rb_mutex_sleep): skip interrupt check before sleep We do not want to risk switching threads before going to sleep because it can cause unexpected wakeups and put us in an unexpected state when used with ConditionVariable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread_sync.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'thread_sync.c') diff --git a/thread_sync.c b/thread_sync.c index 5e511af0db..7b1054b2ac 100644 --- a/thread_sync.c +++ b/thread_sync.c @@ -438,7 +438,7 @@ rb_mutex_cleanup_keeping_mutexes(const rb_thread_t *current_thread) static VALUE rb_mutex_sleep_forever(VALUE time) { - rb_thread_sleep_deadly_allow_spurious_wakeup(); + sleep_forever(GET_THREAD(), SLEEP_DEADLOCKABLE|SLEEP_BEFORE_CHECK_INTS); return Qnil; } @@ -446,7 +446,8 @@ static VALUE rb_mutex_wait_for(VALUE time) { struct timespec *t = (struct timespec*)time; - sleep_timespec(GET_THREAD(), *t, 0); /* permit spurious check */ + /* permit spurious check */ + sleep_timespec(GET_THREAD(), *t, SLEEP_BEFORE_CHECK_INTS); return Qnil; } -- cgit v1.2.3