From: Björn Stenberg Date: Mon, 25 Nov 2013 23:04:28 +0000 (+0100) Subject: connect: Try next ip directly after immediate connect fail X-Git-Tag: curl-7_34_0~44 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b2a55c81061a9f5efcd16a49064410bc1a627720;p=thirdparty%2Fcurl.git connect: Try next ip directly after immediate connect fail 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. --- diff --git a/lib/connect.c b/lib/connect.c index 3cbca1b503..9c38724d63 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; } }