Created
December 4, 2012 17:01
-
-
Save kosaki/4206236 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/thread_pthread.c b/thread_pthread.c | |
index d60cb41..4d055da 100644 | |
--- a/thread_pthread.c | |
+++ b/thread_pthread.c | |
@@ -959,11 +959,13 @@ native_sleep(rb_thread_t *th, struct timeval *timeout_tv) | |
GVL_UNLOCK_BEGIN(); | |
{ | |
+ rb_thread_t *th = ruby_thread_from_native(); | |
+ | |
pthread_mutex_lock(lock); | |
th->unblock.func = ubf_pthread_cond_signal; | |
th->unblock.arg = th; | |
- if (RUBY_VM_INTERRUPTED(th)) { | |
+ if (RUBY_VM_INTERRUPTED(th) || th->status == THREAD_RUNNABLE) { | |
/* interrupted. return immediate */ | |
thread_debug("native_sleep: interrupted before sleep\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
t1がスレッドt2, t3をつくる
t1: t2にjoin。thread_join_m が join_listに自分をつなぐ
t1: native_sleepの直前のCHECK_INTS_BLOCKINGで時間切れコンテキストスイッチ
t2: 死ぬ。thread_func_2でt1のstatusをTHREAD_RUNNABLEにしてRUBY_VM_SET_INTERRUPT()する
t3: 死ぬ
t1: rb_execute_interrupt()でRUBY_VM_SET_INTERRUPTされているので、async errinfoキュー見るがなにも無いので抜ける
t1 native_sleep。もうRUBY_VM_SET_INTERRUPTの痕跡は残っていないので、そのまま寝てしまう。もう起こしてくれる人はいないので刺さる
で th->status が変わっているのでそれを見ればよい。