зеркало из https://github.com/github/ruby.git
* win32/win32.c (rb_w32_select): I hope performance problem was
solved. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
aa21055faf
Коммит
f0bcbbef67
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Sep 17 14:18:15 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
||||||
|
|
||||||
|
* win32/win32.c (rb_w32_select): I hope performance problem was
|
||||||
|
solved.
|
||||||
|
|
||||||
Sat Sep 17 13:45:22 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
Sat Sep 17 13:45:22 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
||||||
|
|
||||||
* win32/win32.c (rb_w32_select): console support is back.
|
* win32/win32.c (rb_w32_select): console support is back.
|
||||||
|
|
|
@ -2025,6 +2025,21 @@ do_select(int nfds, fd_set *rd, fd_set *wr, fd_set *ex,
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
subst(struct timeval *rest, const struct timeval *wait)
|
||||||
|
{
|
||||||
|
while (rest->tv_usec < wait->tv_usec) {
|
||||||
|
if (rest->tv_sec <= wait->tv_sec) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
rest->tv_sec -= 1;
|
||||||
|
rest->tv_usec += 1000 * 1000;
|
||||||
|
}
|
||||||
|
rest->tv_sec -= wait->tv_sec;
|
||||||
|
rest->tv_usec -= wait->tv_usec;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
long
|
long
|
||||||
rb_w32_select(int nfds, fd_set *rd, fd_set *wr, fd_set *ex,
|
rb_w32_select(int nfds, fd_set *rd, fd_set *wr, fd_set *ex,
|
||||||
struct timeval *timeout)
|
struct timeval *timeout)
|
||||||
|
@ -2083,8 +2098,11 @@ rb_w32_select(int nfds, fd_set *rd, fd_set *wr, fd_set *ex,
|
||||||
|
|
||||||
RUBY_CRITICAL(
|
RUBY_CRITICAL(
|
||||||
if (pipe_rd.fd_count || cons_rd.fd_count) {
|
if (pipe_rd.fd_count || cons_rd.fd_count) {
|
||||||
long sec = timeout ? timeout->tv_sec + 1 : 0/*dummy*/;
|
struct timeval rest;
|
||||||
while (!timeout || sec--) {
|
struct timeval wait;
|
||||||
|
if (timeout) rest = *timeout;
|
||||||
|
wait.tv_sec = 0; wait.tv_usec = 10 * 1000; // 10ms
|
||||||
|
do {
|
||||||
fd_set buf; buf.fd_count = 0;
|
fd_set buf; buf.fd_count = 0;
|
||||||
// pipe
|
// pipe
|
||||||
extract_fd(&buf, &pipe_rd, is_readable_pipe);
|
extract_fd(&buf, &pipe_rd, is_readable_pipe);
|
||||||
|
@ -2092,21 +2110,19 @@ rb_w32_select(int nfds, fd_set *rd, fd_set *wr, fd_set *ex,
|
||||||
extract_fd(&buf, &cons_rd, is_readable_console);
|
extract_fd(&buf, &cons_rd, is_readable_console);
|
||||||
// socket
|
// socket
|
||||||
if (buf.fd_count) {
|
if (buf.fd_count) {
|
||||||
struct timeval val; val.tv_sec = 0; val.tv_usec = 0;
|
r = do_select(nfds, rd, wr, ex, &wait);
|
||||||
r = do_select(nfds, rd, wr, ex, &val);
|
|
||||||
if (r >= 0) {
|
if (r >= 0) {
|
||||||
r += buf.fd_count;
|
r += buf.fd_count;
|
||||||
extract_fd(rd, &buf, NULL); // move all `buf' contents into `rd'.
|
extract_fd(rd, &buf, NULL); // move all `buf' contents into `rd'.
|
||||||
}
|
}
|
||||||
// XXX: should I ignore socket error and returns only readable pipe?
|
// XXX: should I ignore socket error and returns readable pipe/console?
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
struct timeval val; val.tv_sec = 1; val.tv_usec = 0;
|
r = do_select(nfds, rd, wr, ex, &wait);
|
||||||
r = do_select(nfds, rd, wr, ex, &val);
|
|
||||||
if (r) break; // readable or error (not pending)
|
if (r) break; // readable or error (not pending)
|
||||||
}
|
}
|
||||||
}
|
} while (!timeout || subst(&rest, &wait));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
r = do_select(nfds, rd, wr, ex, timeout);
|
r = do_select(nfds, rd, wr, ex, timeout);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче