From 73b3b10d8db30d3c6b7c53ae0da64c39b55d899f Mon Sep 17 00:00:00 2001 From: shugo Date: Sat, 5 Nov 2016 06:47:36 +0000 Subject: * lib/net/smtp.rb (tlsconnect): support timeout for TLS handshake. [ruby-core:76893] [Bug #12678] * lib/net/protocol.rb (ssl_socket_connect): new method to implement timeout for TLS handshake. * lib/net/http.rb (connect): use Net::Protocol#ssl_socket_connect. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/net/http.rb | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'lib/net/http.rb') diff --git a/lib/net/http.rb b/lib/net/http.rb index 4738bc621a..25d7dae873 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -930,21 +930,7 @@ module Net #:nodoc: Process.clock_gettime(Process::CLOCK_REALTIME) < @ssl_session.time.to_f + @ssl_session.timeout s.session = @ssl_session if @ssl_session end - if timeout = @open_timeout - while true - raise Net::OpenTimeout if timeout <= 0 - start = Process.clock_gettime Process::CLOCK_MONOTONIC - # to_io is required because SSLSocket doesn't have wait_readable yet - case s.connect_nonblock(exception: false) - when :wait_readable; s.to_io.wait_readable(timeout) - when :wait_writable; s.to_io.wait_writable(timeout) - else; break - end - timeout -= Process.clock_gettime(Process::CLOCK_MONOTONIC) - start - end - else - s.connect - end + ssl_socket_connect(s, @open_timeout) if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE s.post_connection_check(@address) end -- cgit v1.2.3