summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-22 14:01:06 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-22 14:01:06 +0000
commitb866e34f75a3f4e70282d23fdce68fbc45bfc30e (patch)
tree465a3d459965177cc2a7b89395cd4401003c89da /io.c
parent4e1f1ec1a869e8b417b7f638ac4b62945b422b61 (diff)
merge revision(s) 57199,57202,57206,57224: [Backport #13076]
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] thread.c: fix race between read and close * thread.c (rb_thread_fd_close): wait until all threads using the fd finish the operation, not to free the buffer in use. [ruby-core:78845] [Bug #13076] revert a part of r57199 * io.c (io_fillbuf): revert a part of r57199 because it broke IO#getch. see also [Bug #13076] io.c: fix race between read and close * io.c (io_fillbuf): fix race between read and close and bail out 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/branches/ruby_2_3@58058 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 2f27731105..8c207942b6 100644
--- a/io.c
+++ b/io.c
@@ -431,7 +431,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
@@ -1781,6 +1781,7 @@ io_fillbuf(rb_io_t *fptr)
rb_syserr_fail_path(e, path);
}
}
+ if (r > 0) rb_io_check_closed(fptr);
fptr->rbuf.off = 0;
fptr->rbuf.len = (int)r; /* r should be <= rbuf_capa */
if (r == 0)