diff options
author | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-31 01:09:30 +0000 |
---|---|---|
committer | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-31 01:09:30 +0000 |
commit | c5e8627f658c88b2403e7b20637cf25e31feff88 (patch) | |
tree | 0f2b153ac4fb185912f23f4ce60c5c2f99f28d0d /lib/net/http.rb | |
parent | 69a1db96fe63ff3071cb3d272675a1d0470aab01 (diff) | |
download | ruby-c5e8627f658c88b2403e7b20637cf25e31feff88.tar.gz |
Revert "lib/net/http.rb: use connect_timeout instead of Timeout"
This reverts commit 69a1db96fe63ff3071cb3d272675a1d0470aab01.
getaddrinfo(3) doesn't support timeout.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net/http.rb')
-rw-r--r-- | lib/net/http.rb | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb index 8ba15e4054..31cbb7a866 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -942,15 +942,14 @@ module Net #:nodoc: end D "opening connection to #{conn_address}:#{conn_port}..." - begin - s = Socket.tcp(conn_address, conn_port, @local_host, @local_port, connect_timeout: @open_timeout) - rescue Errno::ETIMEDOUT => e - raise Net::OpenTimeout, "Failed to open TCP connection to " + - "#{conn_address}:#{conn_port} (#{e.message})" - rescue => e - raise e, "Failed to open TCP connection to " + - "#{conn_address}:#{conn_port} (#{e.message})" - end + s = Timeout.timeout(@open_timeout, Net::OpenTimeout) { + begin + TCPSocket.open(conn_address, conn_port, @local_host, @local_port) + rescue => e + raise e, "Failed to open TCP connection to " + + "#{conn_address}:#{conn_port} (#{e.message})" + end + } s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) D "opened" if use_ssl? |