summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-16 04:33:53 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-16 04:33:53 +0000
commit525ebb862e3c472123c64134e433b2684ec0db9b (patch)
tree95325ad8f21cb87a23900b6290663acea634b4b7
parent885c16c1d6d3115a8f88ad197f7f7850cebdb344 (diff)
webrick: fix up r60172
By making the socket non-blocking in r60172, TLS/SSL negotiation via the SSL_accept function must handle non-blocking sockets properly and retry on SSL_ERROR_WANT_READ/SSL_ERROR_WANT_WRITE. OpenSSL::SSL::SSLSocket#accept cannot do that properly with a non-blocking socket, so it must use non-blocking logic of OpenSSL::SSL::SSLSocket#accept_nonblock. Thanks to MSP-Greg (Greg L) for finding this. * lib/webrick/server.rb (start_thread): use SSL_accept properly with non-blocking socket. [Bug #14013] [Bug #14005] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--lib/webrick/server.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/webrick/server.rb b/lib/webrick/server.rb
index 52a09f5186..2d678273e5 100644
--- a/lib/webrick/server.rb
+++ b/lib/webrick/server.rb
@@ -295,7 +295,15 @@ module WEBrick
end
if sock.respond_to?(:sync_close=) && @config[:SSLStartImmediately]
WEBrick::Utils.timeout(@config[:RequestTimeout]) do
- sock.accept # OpenSSL::SSL::SSLSocket#accept
+
+ # we must call OpenSSL::SSL::SSLSocket#accept_nonblock until
+ # it stop returning wait_* symbols:
+ case ret = sock.accept_nonblock(exception: false)
+ when :wait_readable, :wait_writable
+ sock.to_io.__send__(ret)
+ else
+ break
+ end while true
end
end
call_callback(:AcceptCallback, sock)