summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-26 14:14:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-26 14:14:18 +0000
commit08ca33e98cbea50f64569445b1856631431a8871 (patch)
treea61c02198f5ac79d33bb1f7df8dcdba474c69d67 /io.c
parentb4aa884f06ee5c40f88e90f312ea6b31c120f308 (diff)
io.c: fix race between read and close
* io.c (io_fillbuf): fix race between read and close, in the case the IO gets closed before the reading thread achieve the lock. [ruby-core:78845] [Bug #13076] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/io.c b/io.c
index af2d54bd3b..d36bd48d5c 100644
--- a/io.c
+++ b/io.c
@@ -424,7 +424,7 @@ rb_cloexec_fcntl_dupfd(int fd, int minfd)
if (!READ_DATA_PENDING(fptr)) {\
WAIT_FD_IN_WIN32(fptr);\
rb_io_check_closed(fptr);\
- }\
+ }\
} while(0)
#ifndef S_ISSOCK
@@ -1775,6 +1775,7 @@ io_fillbuf(rb_io_t *fptr)
rb_syserr_fail_path(e, path);
}
}
+ if (r > 0) READ_CHECK(fptr);
fptr->rbuf.off = 0;
fptr->rbuf.len = (int)r; /* r should be <= rbuf_capa */
if (r == 0)