diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-11-28 14:56:32 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-11-28 14:56:32 +0000 |
commit | 6ab0ff977d84d816cefa7a92c15aacd5b6694087 (patch) | |
tree | 645af2c635e9d5835c04e9136b163940ae4ef0c1 /eval.c | |
parent | 186c8b592a8b5badfd42ff7295c5edb44ef1abdd (diff) |
* eval.c (rb_thread_select): should subtract timeofday() from
limit, not reverse.
* util.c (scan_hex): x is not a hexadecimal digit.
* eval.c (rb_thread_schedule): should treat the case that
select(2) returns 0, if a thread is under both WAIT_SELECT and
WAIT_TIME. Jakub Travnik <J.Travnik@sh.cvut.cz> actually fixed
this bug.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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); |