From a8bdd28d10c2c5981e944e945eed95f6c4ad44bc Mon Sep 17 00:00:00 2001 From: usa Date: Wed, 15 Jun 2011 18:04:13 +0000 Subject: * 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 --- thread.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'thread.c') diff --git a/thread.c b/thread.c index 208c4be074..230e333a40 100644 --- a/thread.c +++ b/thread.c @@ -2537,7 +2537,7 @@ do_select(int n, rb_fdset_t *read, rb_fdset_t *write, rb_fdset_t *except, # endif if (timeout) { -# if defined(__CYGWIN__) || defined(_WIN32) +# if defined(__CYGWIN__) gettimeofday(&start_time, NULL); limit = (double)start_time.tv_sec + (double)start_time.tv_usec*1e-6; # else @@ -2558,7 +2558,7 @@ do_select(int n, rb_fdset_t *read, rb_fdset_t *write, rb_fdset_t *except, retry: lerrno = 0; -#if defined(__CYGWIN__) || defined(_WIN32) +#if defined(__CYGWIN__) { int finish = 0; /* polling duration: 100ms */ @@ -2595,6 +2595,14 @@ do_select(int n, rb_fdset_t *read, rb_fdset_t *write, rb_fdset_t *except, }, 0, 0); } while (result == 0 && !finish); } +#elif defined(_WIN32) + { + rb_thread_t *th = GET_THREAD(); + BLOCKING_REGION({ + result = native_fd_select(n, read, write, except, timeout, th); + if (result < 0) lerrno = errno; + }, ubf_select, th); + } #else BLOCKING_REGION({ result = rb_fd_select(n, read, write, except, timeout); -- cgit v1.2.3