[前][次][番号順一覧][スレッド一覧]

ruby-changes:74187

From: Hiroshi <ko1@a...>
Date: Fri, 21 Oct 2022 21:40:12 +0900 (JST)
Subject: [ruby-changes:74187] f88bff7705 (master): [ruby/net-http] Revert "Replace Timeout.timeout in Net:HTTP#connect"

https://git.ruby-lang.org/ruby.git/commit/?id=f88bff7705

From f88bff770578583a708093f4a0d8b1483a1d2039 Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Fri, 21 Oct 2022 21:33:50 +0900
Subject: [ruby/net-http] Revert "Replace Timeout.timeout in Net:HTTP#connect"

This reverts commit https://github.com/ruby/net-http/commit/753cae3bbccc.

https://github.com/ruby/net-http/commit/98caa38204
---
 lib/net/http.rb | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/lib/net/http.rb b/lib/net/http.rb
index 7e89409c1b..928541f8e8 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -1013,13 +1013,14 @@ module Net   #:nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L1013
       end
 
       debug "opening connection to #{conn_addr}:#{conn_port}..."
-      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 = 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
+      }
       s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
       debug "opened"
       if use_ssl?
-- 
cgit v1.2.3


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]