diff options
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 24 |
1 files changed, 14 insertions, 10 deletions
@@ -7571,6 +7571,7 @@ rb_thread_schedule() double delay, now; /* OK */ int n, max; int need_select = 0; + int select_timeout = 0; rb_thread_pending = 0; if (curr_thread == curr_thread->next @@ -7615,7 +7616,7 @@ rb_thread_schedule() if (max < th->fd) max = th->fd; need_select = 1; if (th->wait_for & WAIT_TIME) { - need_select = 2; + select_timeout = 1; } th->select_value = 0; } @@ -7676,14 +7677,17 @@ rb_thread_schedule() } END_FOREACH_FROM(curr, th); } - if (n == 0 && need_select == 2) { - if (now < 0.0) now = timeofday(); - FOREACH_THREAD_FROM(curr, th) { - if ((th->wait_for & (WAIT_SELECT|WAIT_TIME)) && th->delay < now) { - th->status = THREAD_RUNNABLE; - th->wait_for = 0; - th->select_value = 0; - found = 1; + if (select_timeout && n == 0) { + if (now < 0.0) now = timeofday(); + FOREACH_THREAD_FROM(curr, th) { + if ((th->wait_for & (WAIT_SELECT|WAIT_TIME)) && th->delay < now) { + th->status = THREAD_RUNNABLE; + th->wait_for = 0; + th->select_value = 0; + found = 1; + intersect_fds(&readfds, &th->readfds, max); + intersect_fds(&writefds, &th->writefds, max); + intersect_fds(&exceptfds, &th->exceptfds, max); } } END_FOREACH_FROM(curr, th); @@ -7912,7 +7916,7 @@ rb_thread_select(max, read, write, except, timeout) case ERESTART: #endif if (timeout) { - double d = timeofday() - limit; + double d = limit - timeofday(); tv.tv_sec = (unsigned int)d; tv.tv_usec = (long)((d-(double)tv.tv_sec)*1e6); |