curl-library
[PATCH] connect: Try all addresses in first connection attempt
From: Björn Stenberg <bjorn_at_haxx.se>
Date: Sat, 28 Dec 2013 13:42:18 +0100
Received on 2013-12-28
Date: Sat, 28 Dec 2013 13:42:18 +0100
Bug: If all addresses in the first family fails immediately (due to
"Network unreachable" for example), curl will hang and never try the
next address family. (curl bug #1315)
Fix: Iterate through all address families when to trying establish the
first connection attempt.
Reported-by: Michał Górny and Anthony G. Basile.
Signed-off-by: Björn Stenberg <bjorn_at_haxx.se>
---
lib/connect.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/lib/connect.c b/lib/connect.c
index 4b6ee00..97a0655 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -1104,13 +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;
--
1.8.4.3
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
- application/pgp-signature attachment: Digital signature