diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-15 18:04:13 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-15 18:04:13 +0000 |
commit | a8bdd28d10c2c5981e944e945eed95f6c4ad44bc (patch) | |
tree | ed9f4c66c96113c5832cbc2d0da018ef6af31ce4 /win32/win32.c | |
parent | 3eb1b472e26d65664b96ca261891cebada6fa03f (diff) | |
download | ruby-a8bdd28d10c2c5981e944e945eed95f6c4ad44bc.tar.gz |
* thread.c (do_select): Windows: no need to poll if select(2) is
cancelable.
* thread_win32.c (native_fd_select): new function to make select(2)
cancelable.
* thread_win32.c (rb_w32_check_interrupt): new function for checking
interrupt.
* win32/win32.c (rb_w32_select_with_thread): new function. cancelable
select(2).
* win32/win32.c (rb_w32_select): use above function internally.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32/win32.c')
-rw-r--r-- | win32/win32.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/win32/win32.c b/win32/win32.c index d636b74e2d..b3ffcffa07 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -2591,9 +2591,13 @@ compare(const struct timeval *t1, const struct timeval *t2) } #undef Sleep -int WSAAPI -rb_w32_select(int nfds, fd_set *rd, fd_set *wr, fd_set *ex, - struct timeval *timeout) + +int rb_w32_check_interrupt(void *); /* @internal */ + +/* @internal */ +int +rb_w32_select_with_thread(int nfds, fd_set *rd, fd_set *wr, fd_set *ex, + struct timeval *timeout, void *th) { int r; rb_fdset_t pipe_rd; @@ -2672,6 +2676,10 @@ rb_w32_select(int nfds, fd_set *rd, fd_set *wr, fd_set *ex, wait.tv_sec = 0; wait.tv_usec = 10 * 1000; // 10ms zero.tv_sec = 0; zero.tv_usec = 0; // 0ms for (;;) { + if (th && rb_w32_check_interrupt(th) != WAIT_TIMEOUT) { + r = -1; + break; + } if (nonsock) { // modifying {else,pipe,cons}_rd is safe because // if they are modified, function returns immediately. @@ -2724,6 +2732,13 @@ rb_w32_select(int nfds, fd_set *rd, fd_set *wr, fd_set *ex, return r; } +int WSAAPI +rb_w32_select(int nfds, fd_set *rd, fd_set *wr, fd_set *ex, + struct timeval *timeout) +{ + return rb_w32_select_with_thread(nfds, rd, wr, ex, timeout, 0); +} + static FARPROC get_wsa_extension_function(SOCKET s, GUID *guid) { |