summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-29 22:19:15 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-29 22:19:15 +0000
commit4c1ab82f0623eca91a95d2a44053be22bbce48ad (patch)
tree834609654324abbd63b682824cbb49c80ad3243e
parent708bfd21156828526fe72de2cedecfaca6647dc1 (diff)
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
-rw-r--r--thread_pthread.c17
1 files changed, 17 insertions, 0 deletions
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);
}