From d8f01e098503b0e26ffba391fe9bf189b4b5d715 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Fri, 9 Feb 2024 13:10:08 +0100 Subject: [PATCH] ftp: fix socket wait activity in ftp_domore_getsock - when waiting on the data connection, always add the control socket to the pollset on state STOP or let the pingpong add the socket according to its needs. Reported-by: Fabian Vogt Fixes #12901 Closes #12913 --- lib/ftp.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/ftp.c b/lib/ftp.c index e0590a61eb..53445b3d5a 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -937,24 +937,18 @@ static int ftp_domore_getsock(struct Curl_easy *data, * remote site, or we could wait for that site to connect to us. Or just * handle ordinary commands. */ - DEBUGF(infof(data, "ftp_domore_getsock()")); - if(conn->cfilter[SECONDARYSOCKET] - && !Curl_conn_is_connected(conn, SECONDARYSOCKET)) - return 0; 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 */ + DEBUGASSERT(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD || + (conn->cfilter[SECONDARYSOCKET] && + !Curl_conn_is_connected(conn, SECONDARYSOCKET))); socks[0] = conn->sock[FIRSTSOCKET]; - if(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD) { - socks[1] = conn->sock[SECONDARYSOCKET]; - bits |= GETSOCK_WRITESOCK(1) | GETSOCK_READSOCK(1); - } - - return bits; + /* An unconnected SECONDARY will add its socket by itself + * via its adjust_pollset() */ + return GETSOCK_READSOCK(0); } return Curl_pp_getsock(data, &conn->proto.ftpc.pp, socks); }