Fix Connection Attempt Delay of Socket.tcp (#12291)

The following two commits fix the proper clearing of the Connection Attempt Delay in `TCPSocket.new`.

- b2f610b0ed
- 6f4efaec53

The same fix will be applied to `Socket.tcp`.
This commit is contained in:
Misaki Shioi 2024-12-10 00:08:56 +09:00 committed by GitHub
parent 652b0c13a7
commit b11287706f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2024-12-09 15:09:14 +00:00
Merged-By: shioimm <shioi.mm@gmail.com>

View File

@ -834,15 +834,14 @@ class Socket < BasicSocket
ip_address = failed_ai.ipv6? ? "[#{failed_ai.ip_address}]" : failed_ai.ip_address
last_error = SystemCallError.new("connect(2) for #{ip_address}:#{failed_ai.ip_port}", sockopt.int)
if writable_sockets.any? ||
resolution_store.any_addrinfos? ||
connecting_sockets.any? ||
resolution_store.any_unresolved_family?
user_specified_connect_timeout_at = nil if connecting_sockets.empty?
if writable_sockets.any? || connecting_sockets.any?
# Try other writable socket in next "while"
# Or exit this "while" and try other connection attempt
# Or exit this "while" and wait for connections to be established or hostname resolution in next loop
elsif resolution_store.any_addrinfos? || resolution_store.any_unresolved_family?
# Exit this "while" and try other connection attempt
# Or exit this "while" and wait for hostname resolution in next loop
connection_attempt_delay_expires_at = nil
user_specified_connect_timeout_at = nil
else
raise last_error
end
@ -858,15 +857,14 @@ class Socket < BasicSocket
ip_address = failed_ai.ipv6? ? "[#{failed_ai.ip_address}]" : failed_ai.ip_address
last_error = SystemCallError.new("connect(2) for #{ip_address}:#{failed_ai.ip_port}", sockopt.int)
if writable_sockets.any? ||
resolution_store.any_addrinfos? ||
connecting_sockets.any? ||
resolution_store.any_unresolved_family?
user_specified_connect_timeout_at = nil if connecting_sockets.empty?
# Try other writable socket in next "while"
# Or exit this "while" and try other connection attempt
if except_sockets.any? || connecting_sockets.any?
# Cleanup other except socket in next "each"
# Or exit this "while" and wait for connections to be established or hostname resolution in next loop
elsif resolution_store.any_addrinfos? || resolution_store.any_unresolved_family?
# Exit this "while" and try other connection attempt
# Or exit this "while" and wait for hostname resolution in next loop
connection_attempt_delay_expires_at = nil
user_specified_connect_timeout_at = nil
else
raise last_error
end