[前][次][番号順一覧][スレッド一覧]

ruby-changes:51894

From: normal <ko1@a...>
Date: Mon, 30 Jul 2018 07:19:20 +0900 (JST)
Subject: [ruby-changes:51894] normal:r64108 (trunk): thread_pthread.c (ubf_select): refix [Bug #5343]

normal	2018-07-30 07:19:15 +0900 (Mon, 30 Jul 2018)

  New Revision: 64108

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64108

  Log:
    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]

  Modified files:
    trunk/thread_pthread.c
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 64107)
+++ thread_pthread.c	(revision 64108)
@@ -1172,8 +1172,25 @@ static void https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1172
 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);
 }
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]