aboutsummaryrefslogtreecommitdiff
path: root/lib/ftp.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-05-12 12:06:39 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-05-12 12:06:39 +0000
commitd60c22572b49cde9b839a59510580df079d2d5e2 (patch)
treec67a83d1a6216ec2be4f39117f1934650a67989e /lib/ftp.c
parent1d7ce36791f32039383236e4940994c41cb2a0bf (diff)
Curl_done() and the protocol-specific conn->curl_done() functions now all
take a CURLcode as a second argument, that is non-zero when Curl_done() is called after an error was returned from Curl_do() (or similar).
Diffstat (limited to 'lib/ftp.c')
-rw-r--r--lib/ftp.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index e4a687884..6287b4fa5 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -738,13 +738,14 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
*
* Input argument is already checked for validity.
*/
-CURLcode Curl_ftp_done(struct connectdata *conn)
+CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode status)
{
struct SessionHandle *data = conn->data;
struct FTP *ftp = conn->proto.ftp;
ssize_t nread;
int ftpcode;
CURLcode result=CURLE_OK;
+
bool was_ctl_valid = ftp->ctl_valid;
/* free the dir tree and file parts */
@@ -784,8 +785,24 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
result = CURLE_FTP_COULDNT_RETR_FILE;
}
}
-
- ftp->ctl_valid = was_ctl_valid;
+
+ switch(status) {
+ case CURLE_BAD_DOWNLOAD_RESUME:
+ case CURLE_FTP_WEIRD_PASV_REPLY:
+ case CURLE_FTP_PORT_FAILED:
+ case CURLE_FTP_COULDNT_SET_BINARY:
+ case CURLE_FTP_COULDNT_RETR_FILE:
+ case CURLE_FTP_ACCESS_DENIED:
+ /* the connection stays alive fine even though this happened */
+ /* fall-through */
+ case CURLE_OK: /* doesn't affect the control connection's status */
+ ftp->ctl_valid = was_ctl_valid;
+ break;
+ default: /* by default, an error means the control connection is
+ wedged and should not be used anymore */
+ ftp->ctl_valid = FALSE;
+ break;
+ }
#ifdef HAVE_KRB4
Curl_sec_fflush_fd(conn, conn->sock[SECONDARYSOCKET]);
@@ -794,12 +811,12 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
sclose(conn->sock[SECONDARYSOCKET]);
conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD;
- if(!ftp->no_transfer) {
+ if(!ftp->no_transfer && !status) {
/* Let's see what the server says about the transfer we just performed,
- but lower the timeout as sometimes this connection has died while
- the data has been transfered. This happens when doing through NATs
- etc that abandon old silent connections.
- */
+ * but lower the timeout as sometimes this connection has died while the
+ * data has been transfered. This happens when doing through NATs etc that
+ * abandon old silent connections.
+ */
ftp->response_time = 60; /* give it only a minute for now */
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);