ruby-changes:66002
From: mohamed <ko1@a...>
Date: Wed, 28 Apr 2021 11:04:16 +0900 (JST)
Subject: [ruby-changes:66002] 8a2b7b79ee (master): [ruby/net-http] Replace Timeout.timeout in Net:HTTP#connect
https://git.ruby-lang.org/ruby.git/commit/?id=8a2b7b79ee From 8a2b7b79ee8a1ba487c0b5064c0730b98f5ba438 Mon Sep 17 00:00:00 2001 From: mohamed <mohamed.m.m.hafez@g...> Date: Wed, 13 Jan 2021 14:03:14 -0800 Subject: [ruby/net-http] Replace Timeout.timeout in Net:HTTP#connect Use Socket.tcp's connect_timeout option instead https://github.com/ruby/net-http/commit/753cae3bbc --- lib/net/http.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/net/http.rb b/lib/net/http.rb index 629d678..33f8b56 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -981,14 +981,13 @@ module Net #:nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L981 end D "opening connection to #{conn_addr}:#{conn_port}..." - s = Timeout.timeout(@open_timeout, Net::OpenTimeout) { - begin - TCPSocket.open(conn_addr, conn_port, @local_host, @local_port) - rescue => e - raise e, "Failed to open TCP connection to " + - "#{conn_addr}:#{conn_port} (#{e.message})" - end - } + begin + s = Socket.tcp conn_addr, conn_port, @local_host, @local_port, connect_timeout: @open_timeout + rescue => e + e = Net::OpenTimeout.new(e) if e.is_a?(Errno::ETIMEDOUT) #for compatibility with previous versions + raise e, "Failed to open TCP connection to " + + "#{conn_addr}:#{conn_port} (#{e.message})" + end s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) D "opened" if use_ssl? -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/