From 4c1ab82f0623eca91a95d2a44053be22bbce48ad Mon Sep 17 00:00:00 2001 From: normal Date: Sun, 29 Jul 2018 22:19:15 +0000 Subject: thread_pthread.c (ubf_select): refix [Bug #5343] We still need to to designate a timer thread after registering target thread for the ubf list. Oops :x Note: I was never able to reproduce test/thread/test_queue.rb::test_thr_kill failures on my on Debian machines. [ruby-core:88088] [Misc #14937] [Bug #5343] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread_pthread.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'thread_pthread.c') diff --git a/thread_pthread.c b/thread_pthread.c index 0eed3847b2..b0b40ed5df 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1172,8 +1172,25 @@ static void ubf_select(void *ptr) { rb_thread_t *th = (rb_thread_t *)ptr; + rb_vm_t *vm = th->vm; register_ubf_list(th); + + /* + * ubf_wakeup_thread() doesn't guarantee to wake up a target thread. + * Therefore, we repeatedly call ubf_wakeup_thread() until a target thread + * exit from ubf function. We must designate a timer-thread to perform + * this operation. + */ + rb_native_mutex_lock(&vm->gvl.lock); + if (!vm->gvl.timer) { + native_thread_data_t *last; + + last = list_tail(&vm->gvl.waitq, native_thread_data_t, ubf_list); + if (last) rb_native_cond_signal(&last->sleep_cond); + } + rb_native_mutex_unlock(&vm->gvl.lock); + ubf_wakeup_thread(th); } -- cgit v1.2.3