1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

wait.c: no EOF

* ext/io/wait/wait.c (io_wait_readable): simply returns that IO is
  readable without blocking, but no longer returns EOF.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-04-12 06:10:21 +00:00
parent 1baa57b003
commit a60e00fde8
2 changed files with 12 additions and 11 deletions

View file

@ -1,4 +1,7 @@
Sun Apr 12 15:08:13 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
Sun Apr 12 15:10:18 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/io/wait/wait.c (io_wait_readable): simply returns that IO is
readable without blocking, but no longer returns EOF.
* ext/io/wait/wait.c (io_ready_p, io_wait_readable): try polling
first and check FIONREAD optionally to see if EOF.

View file

@ -117,13 +117,14 @@ io_ready_p(VALUE io)
/*
* call-seq:
* io.wait -> IO, true, false or nil
* io.wait(timeout) -> IO, true, false or nil
* io.wait_readable -> IO, true, false or nil
* io.wait_readable(timeout) -> IO, true, false or nil
* io.wait -> IO, true or nil
* io.wait(timeout) -> IO, true or nil
* io.wait_readable -> IO, true or nil
* io.wait_readable(timeout) -> IO, true or nil
*
* Waits until input is available or times out and returns self or nil when
* EOF is reached.
* Waits until IO is readable without blocking and returns +self+, or
* +nil+ when times out.
* Returns +true+ immediately when buffered data is available.
*/
static VALUE
@ -138,10 +139,7 @@ io_wait_readable(int argc, VALUE *argv, VALUE io)
tv = get_timeout(argc, argv, &timerec);
if (rb_io_read_pending(fptr)) return Qtrue;
if (wait_for_single_fd(fptr, RB_WAITFD_IN, tv)) {
ioctl_arg n;
if (!FIONREAD_POSSIBLE_P(fptr->fd)) return io;
if (ioctl(fptr->fd, FIONREAD, &n)) rb_sys_fail(0);
if (n > 0) return io;
return io;
}
return Qnil;
}