From 01669133187fcc48428ea4985991e99de77a21b3 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Sun, 19 Jul 2020 17:06:10 -0500 Subject: [PATCH 1/3] CI fixes - lib/puma/events.rb, lib/puma/server.rb --- lib/puma/events.rb | 3 ++- lib/puma/server.rb | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/puma/events.rb b/lib/puma/events.rb index 8c2323f73b..c746c9d1a5 100644 --- a/lib/puma/events.rb +++ b/lib/puma/events.rb @@ -65,7 +65,8 @@ def register(hook, obj=nil, &blk) # Write +str+ to +@stdout+ # def log(str) - @stdout.puts format(str) + @stdout.puts format(str) if @stdout.respond_to? :puts + rescue Errno::EPIPE end def write(str) diff --git a/lib/puma/server.rb b/lib/puma/server.rb index 0ef5aa55dc..2ba99f5243 100644 --- a/lib/puma/server.rb +++ b/lib/puma/server.rb @@ -317,7 +317,12 @@ def handle_servers rescue Exception => e @events.unknown_error e, nil, "Exception handling servers" ensure - @check.close unless @check.closed? # Ruby 2.2 issue + 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 + end @notify.close @notify = nil @check = nil @@ -912,7 +917,7 @@ def notify_safely(message) @check, @notify = Puma::Util.pipe unless @notify begin @notify << message - rescue IOError + rescue IOError, NoMethodError, Errno::EPIPE # The server, in another thread, is shutting down Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue rescue RuntimeError => e From 1f40ce031e7df67af4d43f37e295204e824e9b29 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Sun, 19 Jul 2020 17:07:06 -0500 Subject: [PATCH 2/3] CI fixes - test/helper.rb, test/test_integration.rb helper.rb Previous code used #capture_exceptions to add a timeout to every test. That method is called once for set methods and the test method, and once for the teardown methods. New code uses #time_it, which wraps all the methods in one timeout thread. test_integration.rb Add another error to UnixSocket tests. --- test/helper.rb | 7 +++++-- test/test_integration_cluster.rb | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test/helper.rb b/test/helper.rb index 472407076d..fa5cd20ca3 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -58,8 +58,11 @@ module TimeoutEveryTestCase class TestTookTooLong < Timeout::Error end - def capture_exceptions(*) - ::Timeout.timeout(RUBY_ENGINE == 'ruby' ? 60 : 120, TestTookTooLong) { super } + def time_it + t0 = Minitest.clock_time + ::Timeout.timeout(RUBY_ENGINE == 'ruby' ? 60 : 120, TestTookTooLong) { yield } + ensure + self.time = Minitest.clock_time - t0 end end diff --git a/test/test_integration_cluster.rb b/test/test_integration_cluster.rb index 524cd4ae6c..f409443c79 100644 --- a/test/test_integration_cluster.rb +++ b/test/test_integration_cluster.rb @@ -387,7 +387,7 @@ def bad_exit_pids(pids) # used with thread_run to define correct 'refused' errors def thread_run_refused(unix: false) if unix - DARWIN ? [Errno::ENOENT, IOError] : [Errno::ENOENT] + [Errno::ENOENT, IOError] else DARWIN ? [Errno::ECONNREFUSED, Errno::EPIPE, EOFError] : [Errno::ECONNREFUSED] From 4abe18b1f5c5e295f3591cf53c939638a82c5bcc Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Sun, 19 Jul 2020 19:32:33 -0500 Subject: [PATCH 3/3] Update History.md --- History.md | 1 + 1 file changed, 1 insertion(+) diff --git a/History.md b/History.md index 991d7186ce..28570e64fd 100644 --- a/History.md +++ b/History.md @@ -33,6 +33,7 @@ * Log binding on http:// for TCP bindings to make it clickable * Bugfixes + * Improve shutdown reliability (#2312) * Close client http connections made to an ssl server with TLSv1.3 (#2116) * Do not set user_config to quiet by default to allow for file config (#2074) * Always close SSL connection in Puma::ControlCLI (#2211)