1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* thread_pthread.c (ping_signal_thread_list, thread_timer):

fix to keep polling state if there are any ping-tasks.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2011-06-30 08:27:13 +00:00
parent 0c22e9a001
commit d49a61e68f
2 changed files with 15 additions and 4 deletions

View file

@ -1,3 +1,8 @@
Thu Jun 30 17:25:08 2011 Koichi Sasada <ko1@atdot.net>
* thread_pthread.c (ping_signal_thread_list, thread_timer):
fix to keep polling state if there are any ping-tasks.
Thu Jun 30 12:25:34 2011 Koichi Sasada <ko1@atdot.net> Thu Jun 30 12:25:34 2011 Koichi Sasada <ko1@atdot.net>
* thread_pthread.c (rb_thread_create_timer_thread): allocate * thread_pthread.c (rb_thread_create_timer_thread): allocate

View file

@ -963,7 +963,7 @@ ubf_select(void *ptr)
ubf_select_each(th); ubf_select_each(th);
} }
static void static int
ping_signal_thread_list(void) { ping_signal_thread_list(void) {
if (signal_thread_list_anchor.next) { if (signal_thread_list_anchor.next) {
FGLOCK(&signal_thread_list_lock, { FGLOCK(&signal_thread_list_lock, {
@ -975,13 +975,17 @@ ping_signal_thread_list(void) {
list = list->next; list = list->next;
} }
}); });
return 1;
}
else {
return 0;
} }
} }
#else /* USE_SIGNAL_THREAD_LIST */ #else /* USE_SIGNAL_THREAD_LIST */
static void add_signal_thread_list(rb_thread_t *th) { } static void add_signal_thread_list(rb_thread_t *th) { }
static void remove_signal_thread_list(rb_thread_t *th) { } static void remove_signal_thread_list(rb_thread_t *th) { }
#define ubf_select 0 #define ubf_select 0
static void ping_signal_thread_list(void) { } static int ping_signal_thread_list(void) { return 0; }
#endif /* USE_SIGNAL_THREAD_LIST */ #endif /* USE_SIGNAL_THREAD_LIST */
static pthread_t timer_thread_id; static pthread_t timer_thread_id;
@ -1069,17 +1073,19 @@ thread_timer(void *p)
while (system_working > 0) { while (system_working > 0) {
fd_set rfds; fd_set rfds;
int need_polling;
/* timer function */ /* timer function */
ping_signal_thread_list(); need_polling = ping_signal_thread_list();
timer_thread_function(0); timer_thread_function(0);
if (TT_DEBUG) WRITE_CONST(2, "tick\n"); if (TT_DEBUG) WRITE_CONST(2, "tick\n");
/* wait */ /* wait */
FD_ZERO(&rfds); FD_ZERO(&rfds);
FD_SET(timer_thread_pipe[0], &rfds); FD_SET(timer_thread_pipe[0], &rfds);
if (gvl->waiting > 0) { if (gvl->waiting > 0 || need_polling) {
timeout.tv_sec = 0; timeout.tv_sec = 0;
timeout.tv_usec = TIME_QUANTUM_USEC; timeout.tv_usec = TIME_QUANTUM_USEC;