summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-25 15:47:52 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-25 15:47:52 +0000
commit8a14ed3df5361398638a16597602b54f8421b905 (patch)
tree71f22d6141b0d2c9064a5db6baa9f8a4b2d79bfd /thread.c
parentd8b81e525658c56992fc7dcc3290e544e08933f0 (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_2@58093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/thread.c b/thread.c
index ad1e500bc3..85dda61b3a 100644
--- a/thread.c
+++ b/thread.c
@@ -2128,14 +2128,22 @@ rb_thread_fd_close(int fd)
{
rb_vm_t *vm = GET_THREAD()->vm;
rb_thread_t *th = 0;
+ int busy;
+ retry:
+ busy = 0;
list_for_each(&vm->living_threads, th, vmlt_node) {
if (th->waiting_fd == fd) {
VALUE err = th->vm->special_exceptions[ruby_error_closed_stream];
rb_threadptr_pending_interrupt_enque(th, err);
rb_threadptr_interrupt(th);
+ busy = 1;
}
}
+ if (busy) {
+ rb_thread_schedule_limits(0);
+ goto retry;
+ }
}
/*