FTP: fix getsock during DO_MORE state
... when doing upload it would return the wrong values at times. This commit attempts to cleanup the mess. Bug: http://curl.haxx.se/mail/lib-2013-08/0109.html Reported-by: Mike Mio
This commit is contained in:
parent
84f3b3dd44
commit
c4a7ca038e
38
lib/ftp.c
38
lib/ftp.c
@ -872,33 +872,21 @@ static int ftp_domore_getsock(struct connectdata *conn, curl_socket_t *socks,
|
|||||||
return GETSOCK_BLANK;
|
return GETSOCK_BLANK;
|
||||||
|
|
||||||
/* When in DO_MORE state, we could be either waiting for us to connect to a
|
/* When in DO_MORE state, we could be either waiting for us to connect to a
|
||||||
remote site, or we could wait for that site to connect to us. Or just
|
* remote site, or we could wait for that site to connect to us. Or just
|
||||||
handle ordinary commands.
|
* handle ordinary commands.
|
||||||
|
*/
|
||||||
|
|
||||||
When waiting for a connect (in PORT mode), we can be in FTP_STOP state
|
if(FTP_STOP == ftpc->state) {
|
||||||
(or we're in FTP_STOR when we do an upload) and then we wait for the
|
/* if stopped and still in this state, then we're also waiting for a
|
||||||
secondary socket to become writeable. If we're in STOR or STOP in passive
|
connect on the secondary connection */
|
||||||
mode, we already have the seconnd connection done.
|
socks[0] = conn->sock[FIRSTSOCKET];
|
||||||
|
socks[1] = conn->sock[SECONDARYSOCKET];
|
||||||
|
|
||||||
If we're in another state, we're still handling commands on the control
|
return GETSOCK_READSOCK(FIRSTSOCKET) |
|
||||||
(primary) connection.
|
GETSOCK_WRITESOCK(SECONDARYSOCKET);
|
||||||
*/
|
}
|
||||||
|
else
|
||||||
switch(ftpc->state) {
|
|
||||||
case FTP_STOP:
|
|
||||||
case FTP_STOR:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return Curl_pp_getsock(&conn->proto.ftpc.pp, socks, numsocks);
|
return Curl_pp_getsock(&conn->proto.ftpc.pp, socks, numsocks);
|
||||||
}
|
|
||||||
|
|
||||||
socks[0] = conn->sock[SECONDARYSOCKET];
|
|
||||||
if(ftpc->wait_data_conn || !conn->data->set.ftp_use_port) {
|
|
||||||
socks[1] = conn->sock[FIRSTSOCKET];
|
|
||||||
return GETSOCK_READSOCK(0) | GETSOCK_READSOCK(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return GETSOCK_READSOCK(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is called after the FTP_QUOTE state is passed.
|
/* This is called after the FTP_QUOTE state is passed.
|
||||||
@ -2427,6 +2415,8 @@ static CURLcode ftp_state_stor_resp(struct connectdata *conn,
|
|||||||
if(data->set.ftp_use_port) {
|
if(data->set.ftp_use_port) {
|
||||||
bool connected;
|
bool connected;
|
||||||
|
|
||||||
|
state(conn, FTP_STOP); /* no longer in STOR state */
|
||||||
|
|
||||||
result = AllowServerConnect(conn, &connected);
|
result = AllowServerConnect(conn, &connected);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user