summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-11-28 14:56:32 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-11-28 14:56:32 +0000
commitf705c0412a2dfab1791419244a3f2ebb6e91593b (patch)
treed356686713748f52791d4ce73215747ea1c07399 /eval.c
parent1e6c347488a1bf62ac2d4870d7f5de3853003c94 (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/branches/ruby_1_6@1862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/eval.c b/eval.c
index 51ef9c0679..487d5c472b 100644
--- a/eval.c
+++ b/eval.c
@@ -7487,6 +7487,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
@@ -7530,6 +7531,9 @@ rb_thread_schedule()
copy_fds(&exceptfds, &th->exceptfds, th->fd);
if (max < th->fd) max = th->fd;
need_select = 1;
+ if (th->wait_for & WAIT_TIME) {
+ select_timeout = 1;
+ }
th->select_value = 0;
}
if (th->wait_for & WAIT_TIME) {
@@ -7591,6 +7595,21 @@ rb_thread_schedule()
}
END_FOREACH_FROM(curr, th);
}
+ 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);
+ }
if (n > 0) {
now = -1.0;
/* Some descriptors are ready.
@@ -7814,7 +7833,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);