1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 08:08:50 -05:00

ftp: close connection as soon as ABOR has been sent

... and do not send ABOR unless really necessary.

Bug: https://bugzilla.redhat.com/649347
Reported by: Simon H.
This commit is contained in:
Kamil Dudka 2010-11-04 21:44:02 +01:00
parent f96a2641fc
commit c6b97a8278
4 changed files with 11 additions and 7 deletions

View File

@ -3083,10 +3083,9 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
#endif #endif
if(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD) { if(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD) {
if(!result && ftpc->dont_check) if(!result && ftpc->dont_check && data->req.maxdownload > 0)
/* prevent some FTP servers (namely Pure-ftpd) from hanging if we close /* partial download completed */
* the data channel before transferring all data */ result = Curl_pp_sendf(pp, "ABOR");
result = Curl_pp_sendf(&ftpc->pp, "ABOR");
if(conn->ssl[SECONDARYSOCKET].use) { if(conn->ssl[SECONDARYSOCKET].use) {
/* The secondary socket is using SSL so we must close down that part /* The secondary socket is using SSL so we must close down that part
@ -3128,6 +3127,14 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
if(result) if(result)
return result; return result;
if(ftpc->dont_check && data->req.maxdownload > 0) {
/* we have just sent ABOR and there is no reliable way to check if it was
* successful or not; we have to close the connection now */
infof(data, "partial download completed, closing connection\n");
conn->bits.close = TRUE; /* mark for closure */
return result;
}
if(!ftpc->dont_check) { if(!ftpc->dont_check) {
/* 226 Transfer complete, 250 Requested file action okay, completed. */ /* 226 Transfer complete, 250 Requested file action okay, completed. */
if((ftpcode != 226) && (ftpcode != 250)) { if((ftpcode != 226) && (ftpcode != 250)) {

View File

@ -50,7 +50,6 @@ TYPE I
SIZE 1036 SIZE 1036
REST 20 REST 20
RETR 1036 RETR 1036
ABOR
QUIT QUIT
</protocol> </protocol>
<file name="log/curl1036.out"> <file name="log/curl1036.out">

View File

@ -46,7 +46,6 @@ TYPE I
SIZE 110 SIZE 110
REST 20 REST 20
RETR 110 RETR 110
ABOR
QUIT QUIT
</protocol> </protocol>
</verify> </verify>

View File

@ -39,7 +39,6 @@ EPSV
PASV PASV
TYPE I TYPE I
SIZE 122 SIZE 122
ABOR
QUIT QUIT
</protocol> </protocol>
</verify> </verify>