Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit df5c8a7

Browse files
committed
Improve the conditions for clearing the Connection Attempt Delay upon connection failure
This change addresses a case that was overlooked in ruby#12087. In the previous change, the Connection Attempt Delay was cleared at the point of a connection failure only if both of the following conditions were met: - No other sockets were attempting a connection - There were addresses still available to start a new connection In this update, the second condition has been removed. As a result, if name resolution succeeds after a connection failure and new addresses are obtained, it will be able to immediately attempt a connection to one of them. If there are no sockets attempting a connection, no addresses available for connection, and name resolution has completed, an exception will still be raised as before.
1 parent f49a01c commit df5c8a7

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

ext/socket/ipsocket.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,9 +1003,7 @@ init_fast_fallback_inetsock_internal(VALUE v)
10031003
if (connected_fd >= 0) break;
10041004

10051005
if (!in_progress_fds(arg->connection_attempt_fds_size)) {
1006-
if (any_addrinfos(&resolution_store)) {
1007-
connection_attempt_delay_expires_at = NULL;
1008-
} else if (resolution_store.is_all_finised) {
1006+
if (!any_addrinfos(&resolution_store) && resolution_store.is_all_finised) {
10091007
if (local_status < 0) {
10101008
host = arg->local.host;
10111009
serv = arg->local.serv;
@@ -1019,6 +1017,7 @@ init_fast_fallback_inetsock_internal(VALUE v)
10191017
rsock_syserr_fail_host_port(last_error.ecode, syscall, host, serv);
10201018
}
10211019
}
1020+
connection_attempt_delay_expires_at = NULL;
10221021
user_specified_connect_timeout_at = NULL;
10231022
}
10241023
}

0 commit comments

Comments
 (0)