aboutsummaryrefslogtreecommitdiff
path: root/lib/ftp.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-04-27 13:24:06 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-04-27 13:24:06 +0000
commitc64fca1b0cd360cca39b960864ed6f591dbc16ec (patch)
treeb1b584503fb8bf9c4a8e78b51362258614e0cb65 /lib/ftp.c
parent15b2a3af91b67073f14013542af14794f40c3a28 (diff)
Fixed the FTP response reader to deal with timeouts better. Previously it
would reset the timeout for each incoming data, which would make veeery slow responses be allowed to take even more time since the timeout would only be reached if the time between two received data chunks was longer than the set timeout value...
Diffstat (limited to 'lib/ftp.c')
-rw-r--r--lib/ftp.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 47bdcb751..ff43c0b4d 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -210,16 +210,6 @@ int Curl_GetFTPResponse(char *buf,
if (ftpcode)
*ftpcode = 0; /* 0 for errors */
- 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 */
- if(timeout <=0 ) {
- failf(data, "Transfer aborted due to timeout");
- return -SELECT_TIMEOUT; /* already too little time */
- }
- }
-
FD_ZERO (&readfd); /* clear it */
FD_SET (sockfd, &readfd); /* read socket */
@@ -235,6 +225,17 @@ int Curl_GetFTPResponse(char *buf,
keepon=TRUE;
while((nread<BUFSIZE) && (keepon && !error)) {
+ /* check and reset timeout value every lap */
+ 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 */
+ if(timeout <=0 ) {
+ failf(data, "Transfer aborted due to timeout");
+ return -SELECT_TIMEOUT; /* already too little time */
+ }
+ }
+
if(!ftp->cache) {
readfd = rkeepfd; /* set every lap */
interval.tv_sec = timeout;