Issue #5757 has been updated by Tomoyuki Chikanaga.


Bug #5343 ?????脂?蚊???????????с?????
??<???????荅?????????吾????????障????障???????? #5343 ???ャ?? Thread ????????? kill ??? raise ??с??蚊??莨若?帥??翫???????????c????????吟????????障?????с??ubf_select() ??с?? rb_thread_wakeup_timer_thread() ???若?喝?冴?????帥?ゃ????若?鴻????????у??茵?????????翫?????若?違??????????????????????т検??劫ぇ筝?紊??????????с??????????????

diff --git a/thread_pthread.c b/thread_pthread.c
index afef326..16f7674 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -924,6 +924,8 @@ native_sleep(rb_thread_t *th, struct timeval *timeout_tv)
     thread_debug("native_sleep done\n");
 }

+static pthread_t timer_thread_id;
+
 #ifdef USE_SIGNAL_THREAD_LIST
 struct signal_thread_list {
     rb_thread_t *th;
@@ -1018,7 +1020,8 @@ ubf_select(void *ptr)
 {
     rb_thread_t *th = (rb_thread_t *)ptr;
     add_signal_thread_list(th);
-    rb_thread_wakeup_timer_thread(); /* activate timer thread */
+    if ( pthread_self() != timer_thread_id )
+       rb_thread_wakeup_timer_thread(); /* activate timer thread */
     ubf_select_each(th);
 }

@@ -1047,7 +1050,6 @@ ping_signal_thread_list(void) {
 static int ping_signal_thread_list(void) { return 0; }
 #endif /* USE_SIGNAL_THREAD_LIST */

-static pthread_t timer_thread_id;
 static int timer_thread_pipe[2] = {-1, -1};
 static int timer_thread_pipe_owner_process;


----------------------------------------
Bug #5757: main thread???read???select??у????c??????????^C ??с???????罩祉????
http://redmine.ruby-lang.org/issues/5757

Author: Yui NARUSE
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 2.0.0dev (2011-12-12 trunk 34015) [x86_64-freebsd9.0]


FreeBSD 9 ????? ./ruby ??莎????????? ^C ?????????????????????罩祉??障????????
./miniruby ??с?? -e'$stdin.read' ??с??????????с?????

篁?腟???帥????????main thread ??? read ??? select ??у????ゅ?翫????????菴???? blocking region ???
unblock.func ??? ubf_select ???荐???????????????с??????????????????激?違????????ャ??????
1. ??????????鴻????????? sighandler ?????若?違??????rb_thread_wakeup_timer_thread() ?????若?違?????
2. ??帥?ゃ????若?鴻?????????莎激??????thread_timer() -> timer_thread_function() -> rb_threadptr_check_signal() -> rb_threadptr_interrupt() -> (th->unblock.func)(th->unblock.arg) -> ubf_select() -> rb_thread_wakeup_timer_thread() ?????若?違?????
3. ??帥?ゃ????若?鴻?????????莎激??????thread_timer() -> timer_thread_function() -> rb_threadptr_check_signal() -> rb_threadptr_interrupt() -> (th->unblock.func)(th->unblock.arg) -> ubf_select() -> rb_thread_wakeup_timer_thread() ?????若?違?????
4. ??帥?ゃ????若?鴻?????????莎激??????thread_timer() -> timer_thread_function() -> rb_threadptr_check_signal() -> rb_threadptr_interrupt() -> (th->unblock.func)(th->unblock.arg) -> ubf_select() -> rb_thread_wakeup_timer_thread() ?????若?違?????
...

絲丞??????????ゃ????????緇??????????????с????????箴??????違??ubf_select() ?????? rb_thread_wakeup_timer_thread() ?????若?違????????????????????


-- 
http://redmine.ruby-lang.org