aboutsummaryrefslogtreecommitdiff
path: root/lib/connect.c
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2013-12-28 13:42:57 +0100
committerSteve Holme <steve_holme@hotmail.com>2013-12-28 13:17:56 +0000
commit4e1ece2e44f432c2614f2090155c0aaf2226ea80 (patch)
tree4f6720e6b77dcf1f8b1ea0dfd88d5202aa9441db /lib/connect.c
parent28dd47d4d419001fce28eb338f7c1c2dfe6ffb21 (diff)
connect: Try all addresses in first connection attempt
Fixes a bug when all addresses in the first family fail immediately, due to "Network unreachable" for example, curl would hang and never try the next address family. Iterate through all address families when to trying establish the first connection attempt. Bug: http://curl.haxx.se/bug/view.cgi?id=1315 Reported-by: Michal Górny and Anthony G. Basile
Diffstat (limited to 'lib/connect.c')
-rw-r--r--lib/connect.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/connect.c b/lib/connect.c
index 4b6ee00a2..588ac28b5 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -1104,12 +1104,12 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
conn->tempaddr[0]->ai_next == NULL ? timeout_ms : timeout_ms / 2;
/* start connecting to first IP */
- res = singleipconnect(conn, conn->tempaddr[0], &(conn->tempsock[0]));
- while(res != CURLE_OK &&
- conn->tempaddr[0] &&
- conn->tempaddr[0]->ai_next &&
- conn->tempsock[0] == CURL_SOCKET_BAD)
- res = trynextip(conn, FIRSTSOCKET, 0);
+ while(conn->tempaddr[0]) {
+ res = singleipconnect(conn, conn->tempaddr[0], &(conn->tempsock[0]));
+ if(res == CURLE_OK)
+ break;
+ conn->tempaddr[0] = conn->tempaddr[0]->ai_next;
+ }
if(conn->tempsock[0] == CURL_SOCKET_BAD)
return res;