aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2014-03-24 23:21:10 +0100
committerDaniel Stenberg <daniel@haxx.se>2014-04-03 20:38:19 +0200
commitc81021f74796a391be739665fec64431a66325c4 (patch)
tree631049f31cca6c99a51987782ec1ccca78d29a3c
parent97f214d0c9059cd85f634155f6f3c49648953558 (diff)
ftp: in passive data connect wait for happy eyeballs sockets
When doing passive FTP, the multi state function needs to extract and use the happy eyeballs sockets to wait for to check for completion! Bug: http://curl.haxx.se/mail/lib-2014-02/0135.html (ruined) Reported-by: Alan
-rw-r--r--lib/ftp.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index b9faa3a19..8ce57a6de 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -877,13 +877,30 @@ static int ftp_domore_getsock(struct connectdata *conn, curl_socket_t *socks,
*/
if(FTP_STOP == ftpc->state) {
+ int bits = GETSOCK_READSOCK(0);
+
/* if stopped and still in this state, then we're also waiting for a
connect on the secondary connection */
socks[0] = conn->sock[FIRSTSOCKET];
- socks[1] = conn->sock[SECONDARYSOCKET];
- return GETSOCK_READSOCK(FIRSTSOCKET) |
- GETSOCK_WRITESOCK(SECONDARYSOCKET);
+ if(!conn->data->set.ftp_use_port) {
+ int s;
+ int i;
+ /* PORT is used to tell the server to connect to us, and during that we
+ don't do happy eyeballs, but we do if we connect to the server */
+ for(s=1, i=0; i<2; i++) {
+ if(conn->tempsock[i] != CURL_SOCKET_BAD) {
+ socks[s] = conn->tempsock[i];
+ bits |= GETSOCK_WRITESOCK(s++);
+ }
+ }
+ }
+ else {
+ socks[1] = conn->sock[SECONDARYSOCKET];
+ bits |= GETSOCK_WRITESOCK(1);
+ }
+
+ return bits;
}
else
return Curl_pp_getsock(&conn->proto.ftpc.pp, socks, numsocks);