Skip to content

Commit 65aed40

Browse files
authored
Merge pull request #74 from ruby/revert-10
Revert "Replace Timeout.timeout in Net:HTTP#connect"
2 parents d03283d + 98caa38 commit 65aed40

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/net/http.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,13 +1013,14 @@ def connect
10131013
end
10141014

10151015
debug "opening connection to #{conn_addr}:#{conn_port}..."
1016-
begin
1017-
s = Socket.tcp conn_addr, conn_port, @local_host, @local_port, connect_timeout: @open_timeout
1018-
rescue => e
1019-
e = Net::OpenTimeout.new(e) if e.is_a?(Errno::ETIMEDOUT) #for compatibility with previous versions
1020-
raise e, "Failed to open TCP connection to " +
1021-
"#{conn_addr}:#{conn_port} (#{e.message})"
1022-
end
1016+
s = Timeout.timeout(@open_timeout, Net::OpenTimeout) {
1017+
begin
1018+
TCPSocket.open(conn_addr, conn_port, @local_host, @local_port)
1019+
rescue => e
1020+
raise e, "Failed to open TCP connection to " +
1021+
"#{conn_addr}:#{conn_port} (#{e.message})"
1022+
end
1023+
}
10231024
s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
10241025
debug "opened"
10251026
if use_ssl?

0 commit comments

Comments
 (0)