cURL / Mailing Lists / curl-library / Single Mail

curl-library

[PATCH] connect: Try next ip directly after immediate connect fail

From: Björn Stenberg <bjorn_at_haxx.se>
Date: Tue, 26 Nov 2013 00:04:28 +0100

This fixes a rare Happy Eyeballs bug where if the first IP family runs
out of addresses before the second-family-timer fires, and the second
IP family's first connect fails immediately, no further IPs of the
second family are attempted.

---
 lib/connect.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/lib/connect.c b/lib/connect.c
index 3cbca1b..9c38724 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -560,12 +560,19 @@ static CURLcode trynextip(struct connectdata *conn,
       ai = conn->tempaddr[0]->ai_next;
     }
 
-    while(ai && ai->ai_family != family)
-      ai = ai->ai_next;
-
-    if(ai) {
-      rc = singleipconnect(conn, ai, &conn->tempsock[tempindex]);
-      conn->tempaddr[tempindex] = ai;
+    while(ai) {
+      while(ai && ai->ai_family != family)
+        ai = ai->ai_next;
+
+      if(ai) {
+        rc = singleipconnect(conn, ai, &conn->tempsock[tempindex]);
+        conn->tempaddr[tempindex] = ai;
+        if(rc == CURLE_COULDNT_CONNECT) {
+          ai = ai->ai_next;
+          continue;
+        }
+      }
+      break;
     }
   }
 
-- 
1.8.4.rc3
-- 
Björn

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

Received on 2013-11-26