From 2105a0652823c032d48d230b842832711ee5744b Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 11 Mar 2017 18:07:19 +0000 Subject: merge revision(s) 57422: [Backport #13158] io.c: close before wait * io.c (io_close_fptr): notify then close, and wait for other threads before free fptr. [ruby-core:79262] [Bug #13158] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@57872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'thread.c') diff --git a/thread.c b/thread.c index 71e479d38c..4423d742c6 100644 --- a/thread.c +++ b/thread.c @@ -2159,14 +2159,13 @@ rb_threadptr_reset_raised(rb_thread_t *th) return 1; } -void -rb_thread_fd_close(int fd) +int +rb_notify_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) { @@ -2176,10 +2175,7 @@ rb_thread_fd_close(int fd) busy = 1; } } - if (busy) { - rb_thread_schedule_limits(0); - goto retry; - } + return busy; } /* -- cgit v1.2.3