Skip to content

Commit

Permalink
* win32/win32.c, include/ruby/win32.h (rb_w32_io_cancelable_p): renamed
Browse files Browse the repository at this point in the history
  from rb_w32_has_cancel_io().  now it takes a parameter as fd to check
  the fd is console or not, because we cannot cancel console input even
  if we have cancel_io function.

* io.c (WAIT_FD_IN_WIN32): call above function instead of the old one,
  so now we can kill the thread which calls STDIN.gets.
  the problem was reported by ko1 vir IRC.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
unak committed Jul 15, 2011
1 parent e56f2ab commit f15d0de
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/ruby/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,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_io_cancelable_p(int);
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);
Expand Down
2 changes: 1 addition & 1 deletion io.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static int max_file_descriptor = NOFILE;

#if defined(_WIN32)
#define WAIT_FD_IN_WIN32(fptr) \
(rb_w32_has_cancel_io() ? 0 : rb_thread_wait_fd((fptr)->fd))
(rb_w32_io_cancelable_p((fptr)->fd) ? 0 : rb_thread_wait_fd((fptr)->fd))
#else
#define WAIT_FD_IN_WIN32(fptr)
#endif
Expand Down
12 changes: 6 additions & 6 deletions win32/win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,12 +578,6 @@ 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)
{
Expand Down Expand Up @@ -2080,6 +2074,12 @@ set_pioinfo_extra(void)
#define FDEV 0x40 /* file handle refers to device */
#define FTEXT 0x80 /* file handle is in text mode */

int
rb_w32_io_cancelable_p(int fd)
{
return cancel_io != NULL && (is_socket(TO_SOCKET(fd)) || !is_console(TO_SOCKET(fd)));
}

static int
rb_w32_open_osfhandle(intptr_t osfhandle, int flags)
{
Expand Down

0 comments on commit f15d0de

Please sign in to comment.