Project

General

Profile

Backport #6661

Timeout not working with IO on Windows

Added by undur_gongor (Undur Gongor) about 7 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:45920]

Description

This code does not time out as expected when run on Ruby 1.9.3p194 (2012-04-20) [i386-mingw32]:

require 'timeout'
Timeout.timeout(1) { gets }

On different Unix-like OSes it does time out after 1 second with different versions of Ruby.

Associated revisions

Revision 1d15cf4b
Added by naruse (Yui NARUSE) about 7 years ago

merge revision(s) 32549,32557: [Backport #6661]

    * win32/win32.c, include/ruby/win32.h (rb_w32_io_cancelable_p): renamed

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.

    * win32/win32.c (is_socket, is_console): add prototypes to fix compile
      problem with gcc introduced at r32549.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@36244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 36244
Added by naruse (Yui NARUSE) about 7 years ago

merge revision(s) 32549,32557: [Backport #6661]

* win32/win32.c, include/ruby/win32.h (rb_w32_io_cancelable_p): renamed

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.

* win32/win32.c (is_socket, is_console): add prototypes to fix compile
  problem with gcc introduced at r32549.

History

Updated by luislavena (Luis Lavena) about 7 years ago

  • Status changed from Open to Assigned
  • Assignee set to usa (Usaku NAKAMURA)

Updated by usa (Usaku NAKAMURA) about 7 years ago

There is no problem on trunk, but I forgot which change fixed it...
Maybe r34388?

I'll test it later.
If there are those who can check ahead of me, please do it.

#3

Updated by usa (Usaku NAKAMURA) about 7 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport193

Updated by usa (Usaku NAKAMURA) about 7 years ago

  • Assignee changed from usa (Usaku NAKAMURA) to naruse (Yui NARUSE)

r32549 is the right answer.
naruse, could you merge it?

Updated by usa (Usaku NAKAMURA) about 7 years ago

... and, r32557 .

#6

Updated by naruse (Yui NARUSE) about 7 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r36244.
Undur, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 32549,32557: [Backport #6661]

* win32/win32.c, include/ruby/win32.h (rb_w32_io_cancelable_p): renamed

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.

* win32/win32.c (is_socket, is_console): add prototypes to fix compile
  problem with gcc introduced at r32549.

Also available in: Atom PDF