summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-11 13:02:01 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-11 13:02:01 +0000
commit1c13c7fa8864648c018966354b469fe5ff8deaa4 (patch)
tree72bda148cfa099bc4c7523c91f77c7b59dee04c4 /thread.c
parentc093d46f4f217b0e8f6ba683f12a3c287ae60eec (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_4@57838 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 11f325b8a4..71e479d38c 100644
--- a/thread.c
+++ b/thread.c
@@ -2164,14 +2164,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;
+ }
}
/*