From f2d422235b0bf7dc6e7179143296a5e4abf8b9ed Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 3 Sep 2003 22:02:40 +0000 Subject: Early Ehlinger's CURLOPT_FTP_RESPONSE_TIMEOUT patch applied. --- CHANGES | 15 +++++++++++++++ include/curl/curl.h | 10 ++++++++-- lib/ftp.c | 10 +++++++++- lib/url.c | 7 +++++++ lib/urldata.h | 1 + 5 files changed, 40 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 776c9e6d1..d0e02d3db 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,21 @@ Changelog +Early (4 September) +- Added CURLOPT_FTP_RESPONSE_TIMEOUT - allows user to set strict timeout + requirements on the FTP server's ability to respond to individual commands + without placing global requirements on transfer or connect time. Files + affected: + - include/curl/curl.h + Added option CURLOPT_FTP_RESPONSE_TIMEOUT + - lib/ftp.c + Added branch inside Curl_GetFTPResponse to check for + data->set.ftp_response_timeout + - lib/url.c + Modified Curl_setopt to recognize CURLOPT_FTP_RESPONSE_TIMEOUT + - lib/urldata.h + Added ftp_response_timeout to struct UserDefined + Daniel (3 September) - Peter Pentchev found and fixed two problems in the test suite's web server code, that made it segfault at times. diff --git a/include/curl/curl.h b/include/curl/curl.h index 96a8b4b11..10ef77ccb 100644 --- a/include/curl/curl.h +++ b/include/curl/curl.h @@ -29,7 +29,7 @@ /* This is the version number of the libcurl package from which this header file origins: */ -#define LIBCURL_VERSION "7.10.7" +#define LIBCURL_VERSION "7.10.8-test2" /* This is the numeric version of the libcurl version number, meant for easier parsing and comparions by programs. The LIBCURL_VERSION_NUM define will @@ -45,7 +45,7 @@ always a greater number in a more recent release. It makes comparisons with greater than and less than work. */ -#define LIBCURL_VERSION_NUM 0x070a07 +#define LIBCURL_VERSION_NUM 0x070a08 #include @@ -678,6 +678,12 @@ typedef enum { Note that setting multiple bits may cause extra network round-trips. */ CINIT(PROXYAUTH, LONG, 111), + /* FPT Option that changes the timeout, in seconds, associated with + getting a response. This is different from transfer timeout time and + essentially places a demand on the FTP server to acknowledge commands + in a timely manner. */ + CINIT(FTP_RESPONSE_TIMEOUT, LONG , 112), + CURLOPT_LASTENTRY /* the last unused */ } CURLoption; diff --git a/lib/ftp.c b/lib/ftp.c index 529460577..cae5361f2 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -233,7 +233,15 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */ while((*nreadpset.timeout) + if(data->set.ftp_response_timeout ) + /* if CURLOPT_FTP_RESPONSE_TIMEOUT is set, use that to determine + remaining time. Also, use "now" as opposed to "conn->now" + because ftp_response_timeout is only supposed to govern + the response for any given ftp response, not for the time + from connect to the given ftp response. */ + timeout = data->set.ftp_response_timeout - /* timeout time */ + Curl_tvdiff(Curl_tvnow(), now)/1000; /* spent time */ + else if(data->set.timeout) /* if timeout is requested, find out how much remaining time we have */ timeout = data->set.timeout - /* timeout time */ Curl_tvdiff(Curl_tvnow(), conn->now)/1000; /* spent time */ diff --git a/lib/url.c b/lib/url.c index 40b718fee..69c3677b1 100644 --- a/lib/url.c +++ b/lib/url.c @@ -500,6 +500,13 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...) */ data->set.ftp_create_missing_dirs = va_arg( param , long )?TRUE:FALSE; break; + case CURLOPT_FTP_RESPONSE_TIMEOUT: + /* + * An FTP option that specifies how quickly an FTP response must be + * obtained before it is considered failure. + */ + data->set.ftp_response_timeout = va_arg( param , long ); + break; case CURLOPT_FTPLISTONLY: /* * An FTP option that changes the command to one that asks for a list diff --git a/lib/urldata.h b/lib/urldata.h index 907bb5dc6..2a7198055 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -773,6 +773,7 @@ struct UserDefined { void *passwd_client; /* pass to the passwd callback */ long timeout; /* in seconds, 0 means no timeout */ long connecttimeout; /* in seconds, 0 means no timeout */ + long ftp_response_timeout; /* in seconds, 0 means no timeout */ long infilesize; /* size of file to upload, -1 means unknown */ long low_speed_limit; /* bytes/second */ long low_speed_time; /* number of seconds */ -- cgit v1.2.3