]> granicus.if.org Git - curl/commitdiff
connect: Try next ip directly after immediate connect fail
authorBjörn Stenberg <bjorn@haxx.se>
Mon, 25 Nov 2013 23:04:28 +0000 (00:04 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 27 Nov 2013 21:26:43 +0000 (22:26 +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

index 3cbca1b503a626c1d90c2d1eefa90d3283cff27d..9c38724d63d30f1d218a09934a3e2974a432de66 100644 (file)
@@ -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;
     }
   }