Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

control_cli.rb - improve ssl connection shutdown #2211

Merged
merged 1 commit into from Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions History.md
@@ -1,6 +1,7 @@
## Master

* Features
* Improve SSL connection closing in Puma::ControlCLI (#2211)
* Add pumactl `thread-backtraces` command to print thread backtraces (#2053)
* Configuration: `environment` is read from `RAILS_ENV`, if `RACK_ENV` can't be found (#2022)
* Do not set user_config to quiet by default to allow for file config (#2074)
Expand Down
13 changes: 10 additions & 3 deletions lib/puma/control_cli.rb
Expand Up @@ -146,8 +146,9 @@ def send_request
require 'openssl'
OpenSSL::SSL::SSLSocket.new(
TCPSocket.new(uri.host, uri.port),
OpenSSL::SSL::SSLContext.new
).tap(&:connect)
OpenSSL::SSL::SSLContext.new)
.tap { |ssl| ssl.sync_close = true } # default is false
.tap(&:connect)
when "tcp"
TCPSocket.new uri.host, uri.port
when "unix"
Expand Down Expand Up @@ -191,7 +192,13 @@ def send_request
message response.last if PRINTABLE_COMMANDS.include?(@command)
end
ensure
server.close if server && !server.closed?
if server
if uri.scheme == "ssl"
server.sysclose
else
server.close unless server.closed?
end
end
end

def send_signal
Expand Down