mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
emparassing thread bug
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
21f39b43b8
commit
106eb09a38
1 changed files with 20 additions and 9 deletions
29
eval.c
29
eval.c
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue