From 8182f80099f3184455ef1da98ec627f212ab2666 Mon Sep 17 00:00:00 2001 From: Eugene Kenny Date: Sat, 31 Mar 2018 00:58:17 +0100 Subject: [PATCH] Purge interrupt queue when closing socket fails 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 1bb0154f3e..fe5eb070ed 100644 --- a/lib/puma/server.rb +++ b/lib/puma/server.rb @@ -220,7 +220,11 @@ def handle_servers_lopez_mode # 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 @@ def handle_servers # 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