diff options
author | Misaki Shioi <[email protected]> | 2024-12-10 00:08:56 +0900 |
---|---|---|
committer | GitHub <[email protected]> | 2024-12-10 00:08:56 +0900 |
commit | b11287706f691bb5fffede44559132544f553d7f (patch) | |
tree | e6ed9380f495e92a1a81e60984c6fbee1d3fe730 | |
parent | 652b0c13a7a0bb74477cd09d2c65f2292dcd06d8 (diff) |
Fix Connection Attempt Delay of `Socket.tcp` (#12291)
The following two commits fix the proper clearing of the Connection Attempt Delay in `TCPSocket.new`.
- https://github.com/ruby/ruby/pull/12087/commits/b2f610b0edf8f84d9d0fce038f3ebfa9f2cb0223
- https://github.com/ruby/ruby/pull/12223/commits/6f4efaec5352cdeb6cab86036a83f53c9fa5c3d2
The same fix will be applied to `Socket.tcp`.
Notes
Notes:
Merged-By: shioimm <[email protected]>
-rw-r--r-- | ext/socket/lib/socket.rb | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/ext/socket/lib/socket.rb b/ext/socket/lib/socket.rb index f23ca8085d..39fd51b92a 100644 --- a/ext/socket/lib/socket.rb +++ b/ext/socket/lib/socket.rb @@ -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 |