mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
6a574771e6
* lib\puma\accept_nonblock.rb - fix socket closing on error
See:
68ac33a511
* test/test_integration.rb - fix my typo that causes a warning
29 lines
595 B
Ruby
29 lines
595 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'openssl'
|
|
|
|
module OpenSSL
|
|
module SSL
|
|
class SSLServer
|
|
unless public_method_defined? :accept_nonblock
|
|
def accept_nonblock
|
|
sock = @svr.accept_nonblock
|
|
|
|
begin
|
|
ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx)
|
|
ssl.sync_close = true
|
|
ssl.accept if @start_immediately
|
|
ssl
|
|
rescue SSLError => ex
|
|
if ssl
|
|
ssl.close
|
|
else
|
|
sock.close
|
|
end
|
|
raise ex
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|