aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Ynard <linkfanel@yahoo.fr>2012-01-23 10:45:24 +0100
committerDaniel Stenberg <daniel@haxx.se>2012-01-28 14:00:52 +0100
commitf4d3c0cbfb648917a0b78d291ac9855fd12975a9 (patch)
tree164841910bc7aae3bdf8c700017d3224c2cb68b2
parent4d2737bcb2c6713d5eebba09343367b6b4d5580c (diff)
more resilient connection times among IP addresses
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.
-rw-r--r--lib/connect.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/connect.c b/lib/connect.c
index 582782e5c..b5082d896 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -732,6 +732,8 @@ CURLcode Curl_is_connected(struct connectdata *conn,
}
next:
+ conn->timeoutms_per_addr = conn->ip_addr->ai_next == NULL ?
+ allow : allow / 2;
code = trynextip(conn, sockindex, connected);
if(code) {
@@ -1012,9 +1014,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
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;
@@ -1026,14 +1026,17 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
* Connecting with a Curl_addrinfo chain
*/
for(curr_addr = ai; curr_addr; curr_addr = curr_addr->ai_next) {
+ CURLcode res;
- /* start connecting to the IP curr_addr points to */
- CURLcode res =
- singleipconnect(conn, curr_addr,
- /* don't hang when doing multi */
- (data->state.used_interface == Curl_if_multi)?0:
- conn->timeoutms_per_addr, &sockfd, connected);
+ /* 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 */
+ res = singleipconnect(conn, curr_addr,
+ /* don't hang when doing multi */
+ (data->state.used_interface == Curl_if_multi)?0:
+ conn->timeoutms_per_addr, &sockfd, connected);
if(res)
return res;