From 5fb2df9144803f0f80ec1d9fb19d20d433706fef Mon Sep 17 00:00:00 2001 From: Eugene Kenny Date: Mon, 2 Apr 2018 15:03:54 +0100 Subject: [PATCH] Purge interrupt queue when closing socket fails (#1553) This workaround for https://bugs.ruby-lang.org/issues/13632 was applied to all places where IOError is rescued explicitly, but the inline `rescue nil` here will also catch IOError and needs the fix too. --- lib/puma/server.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/puma/server.rb b/lib/puma/server.rb index 1bb0154f..fe5eb070 100644 --- a/lib/puma/server.rb +++ b/lib/puma/server.rb @@ -220,7 +220,11 @@ module Puma # nothing rescue Errno::ECONNABORTED # client closed the socket even before accept - io.close rescue nil + begin + io.close + rescue + Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue + end end end end @@ -372,7 +376,11 @@ module Puma # nothing rescue Errno::ECONNABORTED # client closed the socket even before accept - io.close rescue nil + begin + io.close + rescue + Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue + end end end end