curl-library
[PATCH 2/2] more resilient connection times among IP addresses
Date: Mon, 23 Jan 2012 10:45:24 +0100
When connecting to a domain with multiple IP addresses, allow different,
decreasing connection timeout values. This should guarantee some
connections attempts with sufficiently long timeouts, while still
providing fallback.
--- curl-7.23.1/lib/connect.c 2012-01-20 13:22:10.000000000 +0100
+++ curl-7.23.1/lib/connect.c 2012-01-20 17:17:57.000000000 +0100
@@ -729,6 +729,8 @@
}
next:
+ conn->timeoutms_per_addr = conn->ip_addr->ai_next == NULL ?
+ allow : allow / 2;
code = trynextip(conn, sockindex, connected);
if(code) {
@@ -1052,9 +1054,7 @@
return CURLE_OPERATION_TIMEDOUT;
}
- /* Max time for each address */
conn->num_addr = Curl_num_addresses(remotehost->addr);
- conn->timeoutms_per_addr = timeout_ms / conn->num_addr;
ai = remotehost->addr;
@@ -1067,6 +1067,10 @@
*/
for(curr_addr = ai; curr_addr; curr_addr = curr_addr->ai_next) {
+ /* Max time for the next address */
+ conn->timeoutms_per_addr = curr_addr->ai_next == NULL ?
+ timeout_ms : timeout_ms / 2;
+
/* start connecting to the IP curr_addr points to */
CURLcode res =
singleipconnect(conn, curr_addr,
Regards,
-- Pierre Ynard "Une âme dans un corps, c'est comme un dessin sur une feuille de papier." ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.htmlReceived on 2012-01-23