From d3ae8f3decd57b58c1c9a02aca0a023e12e4f24d Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Wed, 3 Nov 2021 18:31:07 -0500 Subject: [PATCH] server.rb - rescue handling (`Errno::EBADF`) for `@notify.close` (#2745) --- lib/puma/server.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/puma/server.rb b/lib/puma/server.rb index ce94da62e9..4e3255e78d 100644 --- a/lib/puma/server.rb +++ b/lib/puma/server.rb @@ -375,13 +375,14 @@ def handle_servers rescue Exception => e @events.unknown_error e, nil, "Exception handling servers" ensure - begin - @check.close unless @check.closed? - rescue Errno::EBADF, RuntimeError - # RuntimeError is Ruby 2.2 issue, can't modify frozen IOError - # Errno::EBADF is infrequently raised + # RuntimeError is Ruby 2.2 issue, can't modify frozen IOError + # Errno::EBADF is infrequently raised + [@check, @notify].each do |io| + begin + io.close unless io.closed? + rescue Errno::EBADF, RuntimeError + end end - @notify.close @notify = nil @check = nil end