From 02fbc26d59c59170fd358034b04a43d8e9b7c78f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Stenberg?= Date: Tue, 29 Oct 2013 11:51:25 +0100 Subject: connect: Add connection delay to Happy Eyeballs. This patch adds a 200ms delay between the first and second address family socket connection attempts. It also iterates over IP addresses in the order returned by the system, meaning most dual-stack systems will try IPv6 first. Additionally, it refactors the connect code, removing most code that handled synchronous connects. Since all sockets are now non-blocking, the logic can be made simpler. --- lib/ftp.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'lib/ftp.c') diff --git a/lib/ftp.c b/lib/ftp.c index 46ec8a6f6..8879ff1d9 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -1884,7 +1884,6 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, struct Curl_dns_entry *addr=NULL; int rc; unsigned short connectport; /* the local port connect() should use! */ - bool connected; char *str=&data->state.buffer[4]; /* start on the first letter */ if((ftpc->count1 == 0) && @@ -2038,9 +2037,8 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, } } - result = Curl_connecthost(conn, - addr, - &connected); + conn->bits.tcpconnect[SECONDARYSOCKET] = FALSE; + result = Curl_connecthost(conn, addr); Curl_resolv_unlock(data, addr); /* we're done using this address */ @@ -2051,7 +2049,6 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, return result; } - conn->bits.tcpconnect[SECONDARYSOCKET] = connected; /* * When this is used from the multi interface, this might've returned with @@ -2063,15 +2060,6 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, /* this just dumps information about this second connection */ ftp_pasv_verbose(conn, conn->ip_addr, ftpc->newhost, connectport); - if(connected) { - /* Only do the proxy connection magic if we're actually connected. We do - this little trick and send in the same 'connected' variable here again - and it will be set FALSE by proxy_magic() for when for example the - CONNECT procedure doesn't complete */ - infof(data, "Connection to proxy confirmed almost instantly\n"); - result = proxy_magic(conn, ftpc->newhost, ftpc->newport, &connected); - } - conn->bits.tcpconnect[SECONDARYSOCKET] = connected; conn->bits.do_more = TRUE; state(conn, FTP_STOP); /* this phase is completed */ -- cgit v1.2.3