diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-05-24 07:42:34 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-05-24 07:42:34 +0000 |
commit | 106eb09a382fa9003b67a29e33598ef4205b83b9 (patch) | |
tree | 7fb3afe362a288222f5c624b5406e3f89c04ae51 | |
parent | 21f39b43b802e4cc69d42b6e65a462e10aab9846 (diff) | |
download | ruby-106eb09a382fa9003b67a29e33598ef4205b83b9.tar.gz |
emparassing thread bug
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | eval.c | 29 |
1 files changed, 20 insertions, 9 deletions
@@ -6737,7 +6737,7 @@ rb_thread_schedule() FD_ZERO(&writefds); FD_ZERO(&exceptfds); delay = DELAY_INFTY; - now = timeofday(); + now = -1.0; FOREACH_THREAD_FROM(curr, th) { if (!next && (th->status == THREAD_RUNNABLE || th->status == THREAD_TO_KILL)) { @@ -6763,13 +6763,16 @@ rb_thread_schedule() th->select_value = 0; } if (th->wait_for & WAIT_TIME) { - if (th->delay <= now) { - th->delay = 0.0; + double th_delay; + + if (now < 0.0) now = timeofday(); + th_delay = th->delay - now; + if (th_delay <= 0.0) { th->wait_for = 0; th->status = THREAD_RUNNABLE; found = 1; - } else if (th->delay < delay) { - delay = th->delay; + } else if (th_delay < delay) { + delay = th_delay; need_select = 1; } } @@ -6790,9 +6793,8 @@ rb_thread_schedule() delay_ptr = 0; } else { - delay -= now; - delay_tv.tv_sec = (unsigned int)delay; - delay_tv.tv_usec = (long)((delay-(double)delay_tv.tv_sec)*1e6); + delay_tv.tv_sec = delay; + delay_tv.tv_usec = (delay - (double)delay_tv.tv_sec)*1e6; delay_ptr = &delay_tv; } @@ -6815,7 +6817,8 @@ rb_thread_schedule() } END_FOREACH(th); } - if (n > 0) { + if (n >= 0) { + now = -1.0; /* Some descriptors are ready. Make the corresponding threads runnable. */ FOREACH_THREAD_FROM(curr, th) { @@ -6840,6 +6843,14 @@ rb_thread_schedule() th->select_value = n; found = 1; } + if (th->wait_for & WAIT_TIME) { + if (now < 0.0) now = timeofday(); + if (th->delay <= now) { + th->wait_for = 0; + th->status = THREAD_RUNNABLE; + found = 1; + } + } } END_FOREACH_FROM(curr, th); } |