Skip to content

Commit

Permalink
Merge pull request #2312 from MSP-Greg/ci-fixes
Browse files Browse the repository at this point in the history
Improve worker shutdown reliability, CI fixes
  • Loading branch information
nateberkopec committed Jul 20, 2020
2 parents 95942e2 + 4abe18b commit f231633
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions History.md
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion lib/puma/events.rb
Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions lib/puma/server.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions test/helper.rb
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion test/test_integration_cluster.rb
Expand Up @@ -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]
Expand Down

0 comments on commit f231633

Please sign in to comment.