From 5dc6d20cc3535f21cf267923f66b98fac1d93309 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 3 Feb 2012 01:11:37 +0000 Subject: merge revision(s) r34038,34099: * thread_pthread.c (ubf_select): call rb_thread_wakeup_timer_thread() only when it is not timer_thread. [Bug #5757] [ruby-dev:44985] patched by Tomoyuki Chikanaga. * thread_pthread.c (ping_signal_thread_list): remove return value. * thread_pthread.c (check_signal_thread_list): add a new function to check if signal thread list is empty. * thread_pthread.c (thread_timer): check signal thread list after timer_thread_function(). main thread might be added into signal thread list during timer_thread_function(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread_pthread.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'thread_pthread.c') diff --git a/thread_pthread.c b/thread_pthread.c index 255dbf02d2..c6c98f0f2c 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -35,6 +35,7 @@ static void native_cond_broadcast(rb_thread_cond_t *cond); static void native_cond_wait(rb_thread_cond_t *cond, pthread_mutex_t *mutex); static void native_cond_initialize(rb_thread_cond_t *cond, int flags); static void native_cond_destroy(rb_thread_cond_t *cond); +static pthread_t timer_thread_id; #define RB_CONDATTR_CLOCK_MONOTONIC 1 @@ -1009,11 +1010,12 @@ 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); } -static int +static void ping_signal_thread_list(void) { if (signal_thread_list_anchor.next) { FGLOCK(&signal_thread_list_lock, { @@ -1025,20 +1027,25 @@ ping_signal_thread_list(void) { list = list->next; } }); - return 1; } - else { +} + +static int +check_signal_thread_list(void) +{ + if (signal_thread_list_anchor.next) + return 1; + else return 0; - } } #else /* USE_SIGNAL_THREAD_LIST */ static void add_signal_thread_list(rb_thread_t *th) { } static void remove_signal_thread_list(rb_thread_t *th) { } #define ubf_select 0 -static int ping_signal_thread_list(void) { return 0; } +static void ping_signal_thread_list(void) { return; } +static int check_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; @@ -1126,8 +1133,9 @@ thread_timer(void *p) int need_polling; /* timer function */ - need_polling = ping_signal_thread_list(); + ping_signal_thread_list(); timer_thread_function(0); + need_polling = check_signal_thread_list(); if (TT_DEBUG) WRITE_CONST(2, "tick\n"); -- cgit v1.2.3