From d60c22572b49cde9b839a59510580df079d2d5e2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 12 May 2004 12:06:39 +0000 Subject: 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). --- lib/ftp.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'lib/ftp.c') 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); -- cgit v1.2.3