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
This commit is contained in:
normal 2017-10-16 04:33:53 +00:00
Родитель 885c16c1d6
Коммит 525ebb862e
1 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -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)