From 52583c34d1d16ecb33d3d3425dd1d56bebc22e18 Mon Sep 17 00:00:00 2001 From: usa Date: Tue, 11 May 2010 05:09:59 +0000 Subject: [PATCH] merge from trunk (r27718) * win32/win32.c, include/ruby/win32.h (rb_w32_has_cancel_io): new function. * io.c (WAIT_FD_IN_WIN32): check only when it's not cancelable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@27732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ include/ruby/win32.h | 1 + io.c | 5 +++-- win32/win32.c | 6 ++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b97b139dd6..112c5d1c43 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Tue May 11 14:09:21 2010 NAKAMURA Usaku + + * win32/win32.c, include/ruby/win32.h (rb_w32_has_cancel_io): new + function. + + * io.c (WAIT_FD_IN_WIN32): check only when it's not cancelable. + Tue May 11 11:49:44 2010 Nobuyoshi Nakada * ext/sdbm/sdbm.h (DBM): large file support on win32. diff --git a/include/ruby/win32.h b/include/ruby/win32.h index d75c7ea9d3..47a85270a5 100644 --- a/include/ruby/win32.h +++ b/include/ruby/win32.h @@ -222,6 +222,7 @@ struct msghdr { extern int rb_w32_cmdvector(const char *, char ***); extern rb_pid_t rb_w32_pipe_exec(const char *, const char *, int, int *, int *); extern int flock(int fd, int oper); +extern int rb_w32_has_cancel_io(void); extern int rb_w32_is_socket(int); extern int WSAAPI rb_w32_accept(int, struct sockaddr *, int *); extern int WSAAPI rb_w32_bind(int, const struct sockaddr *, int); diff --git a/io.c b/io.c index eccc93b141..00ec9ffdb4 100644 --- a/io.c +++ b/io.c @@ -189,9 +189,10 @@ static int max_file_descriptor = NOFILE; #define READ_CHAR_PENDING(fptr) ((fptr)->cbuf_len) #if defined(_WIN32) -#define WAIT_FD_IN_WIN32(fptr) rb_thread_wait_fd((fptr)->fd); +#define WAIT_FD_IN_WIN32(fptr) \ + (rb_w32_has_cancel_io() ? 0 : rb_thread_wait_fd((fptr)->fd)) #else -#define WAIT_FD_IN_WIN32(fptr) ; +#define WAIT_FD_IN_WIN32(fptr) #endif #define READ_CHECK(fptr) do {\ diff --git a/win32/win32.c b/win32/win32.c index 5b05510209..fa49cf17de 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -548,6 +548,12 @@ init_env(void) typedef BOOL (WINAPI *cancel_io_t)(HANDLE); static cancel_io_t cancel_io = NULL; +int +rb_w32_has_cancel_io(void) +{ + return cancel_io != NULL; +} + static void init_func(void) {