diff options
Diffstat (limited to 'thread_pthread.c')
-rw-r--r-- | thread_pthread.c | 24 |
1 files changed, 16 insertions, 8 deletions
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"); |