]> granicus.if.org Git - curl/commitdiff
ftp: close connection as soon as ABOR has been sent
authorKamil Dudka <kdudka@redhat.com>
Thu, 4 Nov 2010 20:44:02 +0000 (21:44 +0100)
committerKamil Dudka <kdudka@redhat.com>
Mon, 8 Nov 2010 19:50:52 +0000 (20:50 +0100)
... and do not send ABOR unless really necessary.

Bug: https://bugzilla.redhat.com/649347
Reported by: Simon H.

lib/ftp.c
tests/data/test1036
tests/data/test110
tests/data/test122

index 679f2334cda45dff3094bf8e7e08b09215f77d72..d79878e82d84ea4792aaba308b33e8bde86f39a4 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -3083,10 +3083,9 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
 #endif
 
   if(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD) {
-    if(!result && ftpc->dont_check)
-      /* prevent some FTP servers (namely Pure-ftpd) from hanging if we close
-       * the data channel before transferring all data */
-      result = Curl_pp_sendf(&ftpc->pp, "ABOR");
+    if(!result && ftpc->dont_check && data->req.maxdownload > 0)
+      /* partial download completed */
+      result = Curl_pp_sendf(pp, "ABOR");
 
     if(conn->ssl[SECONDARYSOCKET].use) {
       /* 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)
       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) {
       /* 226 Transfer complete, 250 Requested file action okay, completed. */
       if((ftpcode != 226) && (ftpcode != 250)) {
index a31cb458a654f3b4bdc591d93dc90cd4f0dc4311..b8ebc4fc0eb20d64a3abb873841c189fb73b26a0 100644 (file)
@@ -50,7 +50,6 @@ TYPE I
 SIZE 1036\r
 REST 20\r
 RETR 1036\r
-ABOR\r
 QUIT\r
 </protocol>
 <file name="log/curl1036.out">
index 4a094e7e8b2ab3acd423c2c3902c039cadae182e..b63ba8a2dbc67310dcc502335e1e0b8924a6c15d 100644 (file)
@@ -46,7 +46,6 @@ TYPE I
 SIZE 110\r
 REST 20\r
 RETR 110\r
-ABOR\r
 QUIT\r
 </protocol>
 </verify>
index ac60672bb744a92d47b2c9d5853308861da12115..fb1dd05fc3f276abea70a83299e38da2cb059403 100644 (file)
@@ -39,7 +39,6 @@ EPSV
 PASV\r
 TYPE I\r
 SIZE 122\r
-ABOR\r
 QUIT\r
 </protocol>
 </verify>