diff options
author | Daniel Stenberg <daniel@haxx.se> | 2004-02-27 07:08:37 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2004-02-27 07:08:37 +0000 |
commit | 77268e064905931536498a87213ebece96a64f9b (patch) | |
tree | 6296fbe0bfa6d9dd802f7473cf9f1fa0ad437605 | |
parent | 1ceb77b4dcf82cf8eb60690a941dc3cf47a59107 (diff) | |
download | curl-77268e064905931536498a87213ebece96a64f9b.tar.gz |
Joe Halpin made the FTP code send 'QUIT' on the control connection before
it disconnects the TCP connection, like a good ftp client should!
49 files changed, 76 insertions, 10 deletions
@@ -2288,12 +2288,14 @@ CURLcode ftp_perform(struct connectdata *conn, * parts etc as a wrapper to the actual DO function (ftp_perform). * * The input argument is already checked for validity. + * + * ftp->ctl_valid starts out as FALSE, and gets set to TRUE if we reach the + * end of the function. */ CURLcode Curl_ftp(struct connectdata *conn) { CURLcode retcode=CURLE_OK; bool connected=0; - struct SessionHandle *data = conn->data; struct FTP *ftp; @@ -2304,6 +2306,7 @@ CURLcode Curl_ftp(struct connectdata *conn) /* the ftp struct is already inited in ftp_connect() */ ftp = conn->proto.ftp; + ftp->ctl_valid = FALSE; conn->size = -1; /* make sure this is unknown at this point */ Curl_pgrsSetUploadCounter(data, 0); @@ -2386,6 +2389,7 @@ CURLcode Curl_ftp(struct connectdata *conn) else freedirs(ftp); + ftp->ctl_valid = TRUE; return retcode; } @@ -2452,11 +2456,13 @@ CURLcode Curl_ftp_quit(struct connectdata *conn) { ssize_t nread; int ftpcode; - CURLcode ret; + CURLcode ret = CURLE_OK; - ret = Curl_ftpsendf(conn, "%s", "QUIT"); - if(CURLE_OK == ret) - ret = Curl_GetFTPResponse(&nread, conn, &ftpcode); + if(conn->proto.ftp->ctl_valid) { + ret = Curl_ftpsendf(conn, "%s", "QUIT"); + if(CURLE_OK == ret) + ret = Curl_GetFTPResponse(&nread, conn, &ftpcode); + } return ret; } @@ -2472,15 +2478,14 @@ CURLcode Curl_ftp_disconnect(struct connectdata *conn) { struct FTP *ftp= conn->proto.ftp; -#if 0 /* We cannot send quit unconditionally. If this connection is stale or bad in any way, sending quit and waiting around here will make the disconnect wait in vain and cause more problems than we need to. - - Until fixed, we keep this #if 0'ed. To be fixed in 7.11.1. Stay tuned. + + Curl_ftp_quit() will check the state of ftp->ctl_valid. If it's ok it + will try to send the QUIT command, otherwise it will just return. */ (void)Curl_ftp_quit(conn); /* ignore errors on the QUIT */ -#endif /* The FTP session may or may not have been allocated/setup at this point! */ if(ftp) { diff --git a/lib/urldata.h b/lib/urldata.h index 33a3fe120..821a0c37e 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -258,6 +258,10 @@ struct FTP { long response_time; /* When no timeout is given, this is the amount of seconds we await for an FTP response. Initialized in Curl_ftp_connect() */ + bool ctl_valid; /* Tells Curl_ftp_quit() whether or not to do + anything. If the connection has timed out or + been closed, this should be FALSE when it gets + to Curl_ftp_quit() */ }; /**************************************************************************** diff --git a/tests/data/test100 b/tests/data/test100 index 8fbb1714e..aad460161 100644 --- a/tests/data/test100 +++ b/tests/data/test100 @@ -43,5 +43,6 @@ PWD EPSV
TYPE A
LIST
+QUIT
</protocol> </verify> diff --git a/tests/data/test101 b/tests/data/test101 index eabc6e2ef..67f5968e4 100644 --- a/tests/data/test101 +++ b/tests/data/test101 @@ -43,5 +43,6 @@ PWD PORT 127,0,0,1,243,212
TYPE A
LIST
+QUIT
</protocol> </verify> diff --git a/tests/data/test102 b/tests/data/test102 index a124581fd..ebb58e898 100644 --- a/tests/data/test102 +++ b/tests/data/test102 @@ -38,5 +38,6 @@ PASV TYPE I
SIZE 102
RETR 102
+QUIT
</protocol> </verify> diff --git a/tests/data/test103 b/tests/data/test103 index e46391318..d8aa339c3 100644 --- a/tests/data/test103 +++ b/tests/data/test103 @@ -40,5 +40,6 @@ PORT 127,0,0,1,246,33 TYPE I
SIZE 103
RETR 103
+QUIT
</protocol> </verify> diff --git a/tests/data/test104 b/tests/data/test104 index 4a72caec7..b0b9c45ef 100644 --- a/tests/data/test104 +++ b/tests/data/test104 @@ -30,5 +30,6 @@ MDTM 103 TYPE I
SIZE 103
REST 0
+QUIT
</protocol> </verify> diff --git a/tests/data/test105 b/tests/data/test105 index b077ecc75..0245592e3 100644 --- a/tests/data/test105 +++ b/tests/data/test105 @@ -38,5 +38,6 @@ PASV TYPE A
SIZE 103
RETR 103
+QUIT
</protocol> </verify> diff --git a/tests/data/test106 b/tests/data/test106 index c6a66cd1b..359af4f2e 100644 --- a/tests/data/test106 +++ b/tests/data/test106 @@ -35,5 +35,6 @@ EPSV TYPE A
SIZE 106
RETR 106
+QUIT
</protocol> </verify> diff --git a/tests/data/test107 b/tests/data/test107 index bb69f16b7..c97dbb9a4 100644 --- a/tests/data/test107 +++ b/tests/data/test107 @@ -37,5 +37,6 @@ PWD EPSV
TYPE I
STOR 107
+QUIT
</protocol> </verify> diff --git a/tests/data/test108 b/tests/data/test108 index 27c5c6d23..7ab7b4791 100644 --- a/tests/data/test108 +++ b/tests/data/test108 @@ -38,6 +38,7 @@ CWD RETR PORT 127,0,0,1,5,109
TYPE I
STOR 108
+QUIT
</protocol> <upload> Moooooooooooo diff --git a/tests/data/test109 b/tests/data/test109 index 4aad72123..1362d5b31 100644 --- a/tests/data/test109 +++ b/tests/data/test109 @@ -32,6 +32,7 @@ PWD EPSV
TYPE I
APPE 109
+QUIT
</protocol> <upload> Moooooooooooo diff --git a/tests/data/test110 b/tests/data/test110 index 4014daa82..38f40c7b7 100644 --- a/tests/data/test110 +++ b/tests/data/test110 @@ -39,5 +39,6 @@ TYPE I SIZE 110
REST 20
RETR 110
+QUIT
</protocol> </verify> diff --git a/tests/data/test111 b/tests/data/test111 index 78b6141af..0664bfd77 100644 --- a/tests/data/test111 +++ b/tests/data/test111 @@ -32,5 +32,6 @@ PWD EPSV
TYPE I
SIZE 111
+QUIT
</protocol> </verify> diff --git a/tests/data/test112 b/tests/data/test112 index e519d6756..fe3dd52cb 100644 --- a/tests/data/test112 +++ b/tests/data/test112 @@ -31,6 +31,7 @@ PWD EPSV
TYPE I
APPE 112
+QUIT
</protocol> <upload> gonna upload diff --git a/tests/data/test115 b/tests/data/test115 index 204b0ccd9..03a5caf1d 100644 --- a/tests/data/test115 +++ b/tests/data/test115 @@ -30,5 +30,6 @@ PASS curl_by_daniel@haxx.se PWD
EPSV
PASV
+QUIT
</protocol> </verify> diff --git a/tests/data/test116 b/tests/data/test116 index 0bc8620c8..57ad11ae2 100644 --- a/tests/data/test116 +++ b/tests/data/test116 @@ -32,5 +32,6 @@ REPLY PORT 314 bluah you f00l! USER anonymous
PASS curl_by_daniel@haxx.se
PWD
+QUIT
</protocol> </verify> diff --git a/tests/data/test117 b/tests/data/test117 index 428cbee9d..43a10958e 100644 --- a/tests/data/test117 +++ b/tests/data/test117 @@ -31,5 +31,6 @@ PWD EPSV
PASV
TYPE I
+QUIT
</protocol> </verify> diff --git a/tests/data/test118 b/tests/data/test118 index b97c0c961..0cce25cb8 100644 --- a/tests/data/test118 +++ b/tests/data/test118 @@ -33,5 +33,6 @@ PASV TYPE I
SIZE 118
RETR 118
+QUIT
</protocol> </verify> diff --git a/tests/data/test119 b/tests/data/test119 index 2e53a82b2..96d30d7e7 100644 --- a/tests/data/test119 +++ b/tests/data/test119 @@ -35,5 +35,6 @@ PWD TYPE I
SIZE 119
RETR 119
+QUIT
</protocol> </verify> diff --git a/tests/data/test120 b/tests/data/test120 index 2fcf01539..ebc5691cd 100644 --- a/tests/data/test120 +++ b/tests/data/test120 @@ -38,5 +38,6 @@ TYPE I SIZE 120
RETR 120
DELE file
+QUIT
</protocol> </verify> diff --git a/tests/data/test121 b/tests/data/test121 index 64d26f9e2..427d88ba7 100644 --- a/tests/data/test121 +++ b/tests/data/test121 @@ -35,5 +35,6 @@ TYPE I SIZE 121
RETR 121
DELE after_transfer
+QUIT
</protocol> </verify> diff --git a/tests/data/test122 b/tests/data/test122 index 3e385502a..5b7bafe75 100644 --- a/tests/data/test122 +++ b/tests/data/test122 @@ -31,5 +31,6 @@ EPSV PASV
TYPE I
SIZE 122
+QUIT
</protocol> </verify> diff --git a/tests/data/test123 b/tests/data/test123 index 066d70960..3825360b0 100644 --- a/tests/data/test123 +++ b/tests/data/test123 @@ -26,5 +26,6 @@ PASS curl_by_daniel@haxx.se PWD
EPSV
TYPE I
+QUIT
</protocol> </verify> diff --git a/tests/data/test124 b/tests/data/test124 index 721f3271f..f8c206094 100644 --- a/tests/data/test124 +++ b/tests/data/test124 @@ -33,5 +33,6 @@ PASV TYPE I
SIZE 124
RETR 124
+QUIT
</protocol> </verify> diff --git a/tests/data/test125 b/tests/data/test125 index 57f8e0105..715eb472e 100644 --- a/tests/data/test125 +++ b/tests/data/test125 @@ -28,5 +28,6 @@ USER anonymous PASS curl_by_daniel@haxx.se
PWD
CWD path
+QUIT
</protocol> </verify> diff --git a/tests/data/test126 b/tests/data/test126 index 1c3216523..e670a2550 100644 --- a/tests/data/test126 +++ b/tests/data/test126 @@ -33,5 +33,6 @@ EPSV TYPE I
SIZE 126
RETR 126
+QUIT
</protocol> </verify> diff --git a/tests/data/test127 b/tests/data/test127 index aafe559d1..5df4e6aff 100644 --- a/tests/data/test127 +++ b/tests/data/test127 @@ -31,5 +31,6 @@ PASV TYPE I
SIZE 127
RETR 127
+QUIT
</protocol> </verify> diff --git a/tests/data/test128 b/tests/data/test128 index a09631e0c..8e5d99106 100644 --- a/tests/data/test128 +++ b/tests/data/test128 @@ -33,6 +33,7 @@ PWD EPSV
TYPE I
STOR 128
+QUIT
</protocol> <upload> file
diff --git a/tests/data/test130 b/tests/data/test130 index 5441f1c35..90cd4f753 100644 --- a/tests/data/test130 +++ b/tests/data/test130 @@ -51,5 +51,6 @@ PWD EPSV
TYPE A
LIST
+QUIT
</protocol> </verify> diff --git a/tests/data/test131 b/tests/data/test131 index 767fc2c84..84d3fcce8 100644 --- a/tests/data/test131 +++ b/tests/data/test131 @@ -51,5 +51,6 @@ PWD EPSV
TYPE A
LIST
+QUIT
</protocol> </verify> diff --git a/tests/data/test132 b/tests/data/test132 index 1d5cf5385..d3c2711dc 100644 --- a/tests/data/test132 +++ b/tests/data/test132 @@ -51,5 +51,6 @@ PWD EPSV
TYPE A
LIST
+QUIT
</protocol> </verify> diff --git a/tests/data/test133 b/tests/data/test133 index f05dd1f29..d2dad20c7 100644 --- a/tests/data/test133 +++ b/tests/data/test133 @@ -51,5 +51,6 @@ PWD EPSV
TYPE A
LIST
+QUIT
</protocol> </verify> diff --git a/tests/data/test134 b/tests/data/test134 index ae5564bc7..949ef4257 100644 --- a/tests/data/test134 +++ b/tests/data/test134 @@ -51,5 +51,6 @@ PWD EPSV
TYPE A
LIST
+QUIT
</protocol> </verify> diff --git a/tests/data/test135 b/tests/data/test135 index 5d63c2954..d8f4546cf 100644 --- a/tests/data/test135 +++ b/tests/data/test135 @@ -38,5 +38,6 @@ TYPE I SIZE 135
REST 4
RETR 135
+QUIT
</protocol> </verify> diff --git a/tests/data/test136 b/tests/data/test136 index 3847f8f46..5e6059bd3 100644 --- a/tests/data/test136 +++ b/tests/data/test136 @@ -28,5 +28,6 @@ EPSV TYPE I
SIZE 136
RETR 136
+QUIT
</protocol> </verify> diff --git a/tests/data/test137 b/tests/data/test137 index 65a7bc762..94b2d6723 100644 --- a/tests/data/test137 +++ b/tests/data/test137 @@ -33,5 +33,6 @@ EPSV TYPE I
SIZE 137
RETR 137
+QUIT
</protocol> </verify> diff --git a/tests/data/test138 b/tests/data/test138 index af862e74e..76c91120a 100644 --- a/tests/data/test138 +++ b/tests/data/test138 @@ -36,5 +36,6 @@ EPSV TYPE I
SIZE 138
RETR 138
+QUIT
</protocol> </verify> diff --git a/tests/data/test139 b/tests/data/test139 index 8d58a9b4e..95fc7958c 100644 --- a/tests/data/test139 +++ b/tests/data/test139 @@ -33,5 +33,6 @@ EPSV TYPE I
SIZE 139
RETR 139
+QUIT
</protocol> </verify> diff --git a/tests/data/test140 b/tests/data/test140 index e0718e111..5112dfa91 100644 --- a/tests/data/test140 +++ b/tests/data/test140 @@ -27,6 +27,7 @@ USER anonymous PASS curl_by_daniel@haxx.se
PWD
CWD blalbla
-MDTM 140 +MDTM 140
+QUIT
</protocol> </verify> diff --git a/tests/data/test141 b/tests/data/test141 index 2088f93aa..f47de51de 100644 --- a/tests/data/test141 +++ b/tests/data/test141 @@ -31,6 +31,7 @@ MDTM 141 TYPE I
SIZE 141
REST 0
+QUIT
</protocol> <stdout> Last-Modified: Wed, 09 Apr 2003 10:26:59 GMT diff --git a/tests/data/test143 b/tests/data/test143 index 567a2d672..c8a8cbbc3 100644 --- a/tests/data/test143 +++ b/tests/data/test143 @@ -30,5 +30,6 @@ EPSV TYPE A
SIZE 143
RETR 143
+QUIT
</protocol> </verify> diff --git a/tests/data/test144 b/tests/data/test144 index 5ca145dc3..7afaf9433 100644 --- a/tests/data/test144 +++ b/tests/data/test144 @@ -35,5 +35,6 @@ PWD PORT 127,0,0,1,243,212
TYPE A
NLST
+QUIT
</protocol> </verify> diff --git a/tests/data/test145 b/tests/data/test145 index 03f3804cf..3747a98b5 100644 --- a/tests/data/test145 +++ b/tests/data/test145 @@ -38,5 +38,6 @@ PWD PORT 127,0,0,1,243,212
TYPE A
NLST
+QUIT
</protocol> </verify> diff --git a/tests/data/test146 b/tests/data/test146 index 88690c954..1909b6b8c 100644 --- a/tests/data/test146 +++ b/tests/data/test146 @@ -42,5 +42,6 @@ EPSV TYPE I
SIZE 146
RETR 146
+QUIT
</protocol> </verify> diff --git a/tests/data/test147 b/tests/data/test147 index 9fbcaf26e..35f7f6676 100644 --- a/tests/data/test147 +++ b/tests/data/test147 @@ -44,5 +44,6 @@ EPSV TYPE I
SIZE 147
RETR 147
+QUIT
</protocol> </verify> diff --git a/tests/data/test148 b/tests/data/test148 index ba0e783a9..454fee3ae 100644 --- a/tests/data/test148 +++ b/tests/data/test148 @@ -37,5 +37,6 @@ PASS curl_by_daniel@haxx.se PWD
CWD attempt
MKD attempt
+QUIT
</protocol> </verify> diff --git a/tests/data/test149 b/tests/data/test149 index 2a8097baa..b42477b79 100644 --- a/tests/data/test149 +++ b/tests/data/test149 @@ -39,6 +39,7 @@ CWD dir2 EPSV
TYPE I
STOR 148
+QUIT
</protocol> <file name="log/upload148"> send away this contents diff --git a/tests/data/test505 b/tests/data/test505 index 734899545..84cb00910 100644 --- a/tests/data/test505 +++ b/tests/data/test505 @@ -44,4 +44,15 @@ upload works? </upload> +<protocol> +USER anonymous
+PASS curl_by_daniel@haxx.se
+PWD
+EPSV
+TYPE I
+STOR 505
+RNFR 505
+RNTO 505-forreal
+QUIT
+</protocol> </verify> |