diff options
author | Misaki Shioi <[email protected]> | 2024-11-25 14:10:54 +0900 |
---|---|---|
committer | GitHub <[email protected]> | 2024-11-25 14:10:54 +0900 |
commit | ff5fc4b5a13e0833d306d472a0a7633f6b838f86 (patch) | |
tree | b3260649a358a743c7fb271386034ea4f4727066 /ext/socket/tcpsocket.c | |
parent | b305df8c78d7c71ec8cfb96c74fa44d24797e7e9 (diff) |
Do not save the last error without sockets in the connection attempt (#12153)
* Do not save the last_error if there are no sockets waiting to be connected
In this implementation, the results of both name resolution and connection attempts are awaited using select(2).
When it returned, the implementation attempted to check for connections even if there were no sockets currently attempting to connect, treating the absence of connected sockets as a connection failure.
With this fix, it will no longer check for connections when there are no sockets waiting to be connected.
Additionally, the following minor fixes have been made:
* Handle failure of getsockopt(2) and removed unnecessary continue in the loop
* Tweak: Use common API to check in_progress_fds
* Safely call TCPServer.new in test
* Set empty writefds when there is no socket waiting to be connected
* Enable fast_fallback option
Notes
Notes:
Merged-By: shioimm <[email protected]>
Diffstat (limited to 'ext/socket/tcpsocket.c')
-rw-r--r-- | ext/socket/tcpsocket.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/ext/socket/tcpsocket.c b/ext/socket/tcpsocket.c index 10b4810869..3c03e89e0d 100644 --- a/ext/socket/tcpsocket.c +++ b/ext/socket/tcpsocket.c @@ -20,14 +20,17 @@ * * Starting from Ruby 3.4, this method operates according to the * Happy Eyeballs Version 2 ({RFC 8305}[https://datatracker.ietf.org/doc/html/rfc8305]) - * algorithm with *fast_fallback:true+, except on Windows. + * algorithm by default, except on Windows. + * + * To make it behave the same as in Ruby 3.3 and earlier, + * explicitly specify the option +fast_fallback:false+. * * Happy Eyeballs Version 2 is not provided on Windows, * and it behaves the same as in Ruby 3.3 and earlier. * * [:resolv_timeout] Specifies the timeout in seconds from when the hostname resolution starts. * [:connect_timeout] This method sequentially attempts connecting to all candidate destination addresses.<br>The +connect_timeout+ specifies the timeout in seconds from the start of the connection attempt to the last candidate.<br>By default, all connection attempts continue until the timeout occurs.<br>When +fast_fallback:false+ is explicitly specified,<br>a timeout is set for each connection attempt and any connection attempt that exceeds its timeout will be canceled. - * [:fast_fallback] Enables the Happy Eyeballs Version 2 algorithm (disabled by default). + * [:fast_fallback] Enables the Happy Eyeballs Version 2 algorithm (enabled by default). * * === Happy Eyeballs Version 2 * Happy Eyeballs Version 2 ({RFC 8305}[https://datatracker.ietf.org/doc/html/rfc8305]) @@ -57,7 +60,7 @@ tcp_init(int argc, VALUE *argv, VALUE sock) VALUE kwargs[4]; VALUE resolv_timeout = Qnil; VALUE connect_timeout = Qnil; - VALUE fast_fallback = Qfalse; + VALUE fast_fallback = Qtrue; VALUE test_mode_settings = Qnil; if (!keyword_ids[0]) { |