merge revision(s) 21165:

* eval.c (rb_thread_schedule): Don't change status of threads which
	  don't run next even if select notify readability/writability.
	  [ruby-core:20446]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@22478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shyouhei 2009-02-21 15:19:29 +00:00
parent 28d53ca8c8
commit d842d1bcc4
3 changed files with 36 additions and 21 deletions

View file

@ -1,3 +1,9 @@
Sun Feb 22 00:19:05 2009 Tanaka Akira <akr@fsij.org>
* eval.c (rb_thread_schedule): Don't change status of threads which
don't run next even if select notify readability/writability.
[ruby-core:20446]
Fri Feb 20 20:43:13 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> Fri Feb 20 20:43:13 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/optparse.rb (OptionParser::List#summarize): gives priority * lib/optparse.rb (OptionParser::List#summarize): gives priority

43
eval.c
View file

@ -10959,6 +10959,7 @@ rb_thread_schedule()
rb_thread_t next; /* OK */ rb_thread_t next; /* OK */
rb_thread_t th; rb_thread_t th;
rb_thread_t curr; rb_thread_t curr;
rb_thread_t th_found = 0;
int found = 0; int found = 0;
fd_set readfds; fd_set readfds;
@ -11104,28 +11105,22 @@ rb_thread_schedule()
if (n > 0) { if (n > 0) {
now = -1.0; now = -1.0;
/* Some descriptors are ready. /* Some descriptors are ready.
Make the corresponding threads runnable. */ * Choose a thread which may run next.
* Don't change the status of threads which don't run next.
*/
FOREACH_THREAD_FROM(curr, th) { FOREACH_THREAD_FROM(curr, th) {
if ((th->wait_for&WAIT_FD) && FD_ISSET(th->fd, &readfds)) { if ((th->wait_for&WAIT_FD) && FD_ISSET(th->fd, &readfds)) {
/* Wake up only one thread per fd. */ th_found = th;
FD_CLR(th->fd, &readfds);
th->status = THREAD_RUNNABLE;
th->fd = 0;
th->wait_for = 0;
found = 1; found = 1;
break;
} }
if ((th->wait_for&WAIT_SELECT) && if ((th->wait_for&WAIT_SELECT) &&
(match_fds(&readfds, &th->readfds, max) || (match_fds(&readfds, &th->readfds, max) ||
match_fds(&writefds, &th->writefds, max) || match_fds(&writefds, &th->writefds, max) ||
match_fds(&exceptfds, &th->exceptfds, max))) { match_fds(&exceptfds, &th->exceptfds, max))) {
/* Wake up only one thread per fd. */ th_found = th;
th->status = THREAD_RUNNABLE; found = 1;
th->wait_for = 0; break;
n = intersect_fds(&readfds, &th->readfds, max) +
intersect_fds(&writefds, &th->writefds, max) +
intersect_fds(&exceptfds, &th->exceptfds, max);
th->select_value = n;
found = 1;
} }
} }
END_FOREACH_FROM(curr, th); END_FOREACH_FROM(curr, th);
@ -11141,9 +11136,23 @@ rb_thread_schedule()
next = th; next = th;
break; break;
} }
if (th->status == THREAD_RUNNABLE && th->stk_ptr) { if ((th->status == THREAD_RUNNABLE || th == th_found) && th->stk_ptr) {
if (!next || next->priority < th->priority) if (!next || next->priority < th->priority) {
next = th; if (th == th_found) {
th_found->status = THREAD_RUNNABLE;
th_found->wait_for = 0;
if (th->wait_for&WAIT_FD) {
th_found->fd = 0;
}
else { /* th->wait_for&WAIT_SELECT */
n = intersect_fds(&readfds, &th_found->readfds, max) +
intersect_fds(&writefds, &th_found->writefds, max) +
intersect_fds(&exceptfds, &th_found->exceptfds, max);
th_found->select_value = n;
}
}
next = th;
}
} }
} }
END_FOREACH_FROM(curr, th); END_FOREACH_FROM(curr, th);

View file

@ -1,15 +1,15 @@
#define RUBY_VERSION "1.8.7" #define RUBY_VERSION "1.8.7"
#define RUBY_RELEASE_DATE "2009-02-20" #define RUBY_RELEASE_DATE "2009-02-22"
#define RUBY_VERSION_CODE 187 #define RUBY_VERSION_CODE 187
#define RUBY_RELEASE_CODE 20090220 #define RUBY_RELEASE_CODE 20090222
#define RUBY_PATCHLEVEL 134 #define RUBY_PATCHLEVEL 135
#define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8 #define RUBY_VERSION_MINOR 8
#define RUBY_VERSION_TEENY 7 #define RUBY_VERSION_TEENY 7
#define RUBY_RELEASE_YEAR 2009 #define RUBY_RELEASE_YEAR 2009
#define RUBY_RELEASE_MONTH 2 #define RUBY_RELEASE_MONTH 2
#define RUBY_RELEASE_DAY 20 #define RUBY_RELEASE_DAY 22
#ifdef RUBY_EXTERN #ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[]; RUBY_EXTERN const char ruby_version[];