summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/io.c b/io.c
index cac73d784b..f7898b61d4 100644
--- a/io.c
+++ b/io.c
@@ -608,6 +608,9 @@ rb_io_wait_readable(int f)
{
rb_fdset_t rfds;
+ if (f < 0) {
+ rb_raise(rb_eIOError, "closed stream");
+ }
switch (errno) {
case EINTR:
#if defined(ERESTART)
@@ -650,6 +653,9 @@ rb_io_wait_writable(int f)
{
rb_fdset_t wfds;
+ if (f < 0) {
+ rb_raise(rb_eIOError, "closed stream");
+ }
switch (errno) {
case EINTR:
#if defined(ERESTART)
@@ -1484,11 +1490,8 @@ io_getpartial(int argc, VALUE *argv, VALUE io, int nonblock)
if (RSTRING_LEN(str) != len) goto modified;
if (nonblock) {
rb_io_set_nonblock(fptr);
- n = rb_read_internal(fptr->fd, RSTRING_PTR(str), len);
}
- else {
- n = rb_read_internal(fptr->fd, RSTRING_PTR(str), len);
- }
+ n = rb_read_internal(fptr->fd, RSTRING_PTR(str), len);
if (n < 0) {
if (!nonblock && rb_io_wait_readable(fptr->fd))
goto again;