]> granicus.if.org Git - curl/commitdiff
- Made the pingpong timeout code properly deal with the response timeout AND
authorDaniel Stenberg <daniel@haxx.se>
Tue, 2 Mar 2010 13:26:23 +0000 (13:26 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 2 Mar 2010 13:26:23 +0000 (13:26 +0000)
  the global timeout if set. Also, as was reported in the bug report #2956437
  by Ryan Chan, the time stamp to use as basis for the per command timeout was
  not set properly in the DONE phase for FTP (and not for SMTP) so I fixed
  that just now. This was a regression compared to 7.19.7 due to the
  conversion of FTP code over to the generic pingpong concepts.

  http://curl.haxx.se/bug/view.cgi?id=2956437

CHANGES
RELEASE-NOTES
lib/ftp.c
lib/pingpong.c
lib/smtp.c

diff --git a/CHANGES b/CHANGES
index 3448d16b70e1114f90f493204a06c95b524389ef..effef4095eef42847713f33426bf66fe3be699ed 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,16 @@
 
                                   Changelog
 
+Daniel Stenberg (2 Mar 2010)
+- Made the pingpong timeout code properly deal with the response timeout AND
+  the global timeout if set. Also, as was reported in the bug report #2956437
+  by Ryan Chan, the time stamp to use as basis for the per command timeout was
+  not set properly in the DONE phase for FTP (and not for SMTP) so I fixed
+  that just now. This was a regression compared to 7.19.7 due to the
+  conversion of FTP code over to the generic pingpong concepts.
+
+  http://curl.haxx.se/bug/view.cgi?id=2956437
+
 Daniel Stenberg (1 Mar 2010)
 - Ben Greear provided an update for TFTP that fixes upload.
 
index b6e2b4ea3012c02000d073694280741cade7e636..f47f6944f593863c39e2c6d5913827789acd89cc 100644 (file)
@@ -23,6 +23,7 @@ This release includes the following bugfixes:
  o off-by-one in the chunked encoding trailer parser
  o superfluous blocking for OpenSSL-based SSL connects and multi interface
  o TFTP upload
+ o FTP timeouts after file transferred completely
 
 This release includes the following known bugs:
 
@@ -32,6 +33,7 @@ This release would not have looked like this without help, code, reports and
 advice from friends like these:
 
  Steven M. Schweda, Yang Tse, Jack Zhang, Tom Donovan, Martin Hager,
- Daniel Fandrich, Patrick Monnerat, Pat Ray, Wesley Miaw, Ben Greear
+ Daniel Fandrich, Patrick Monnerat, Pat Ray, Wesley Miaw, Ben Greear,
+ Ryan Chan
 
         Thanks! (and sorry if I forgot to mention someone)
index 85419009eb2989fb4790341ba8e567d8d79a32a1..552ecf8ee7f62773b54fd7d8739b575754f934a6 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -3071,6 +3071,7 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
     long old_time = pp->response_time;
 
     pp->response_time = 60*1000; /* give it only a minute for now */
+    pp->response = Curl_tvnow(); /* timeout relative now */
 
     result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
 
index 6f27f57612d3651551dd8a49c1dec8e40c808e38..072e56207c31eee52b9c74e55b76c4fe3d5a8be6 100644 (file)
@@ -50,23 +50,28 @@ long Curl_pp_state_timeout(struct pingpong *pp)
   struct connectdata *conn = pp->conn;
   struct SessionHandle *data=conn->data;
   long timeout_ms; /* in milliseconds */
+  long timeout2_ms; /* in milliseconds */
+  long response_time= (data->set.server_response_timeout)?
+    data->set.server_response_timeout: pp->response_time;
 
-  if(data->set.server_response_timeout )
-    /* if CURLOPT_SERVER_RESPONSE_TIMEOUT is set, use that to determine
-       remaining time.  Also, use pp->response because SERVER_RESPONSE_TIMEOUT
-       is supposed to govern the response for any given server response, not
-       for the time from connect to the given server response. */
-    timeout_ms = data->set.server_response_timeout - /* timeout time */
-      Curl_tvdiff(Curl_tvnow(), pp->response); /* spent time */
-  else if(data->set.timeout)
+  /* if CURLOPT_SERVER_RESPONSE_TIMEOUT is set, use that to determine
+     remaining time, or use pp->response because SERVER_RESPONSE_TIMEOUT is
+     supposed to govern the response for any given server response, not for
+     the time from connect to the given server response. */
+
+  /* Without a requested timeout, we only wait 'response_time' seconds for the
+     full response to arrive before we bail out */
+  timeout_ms = response_time -
+    Curl_tvdiff(Curl_tvnow(), pp->response); /* spent time */
+
+  if(data->set.timeout) {
     /* if timeout is requested, find out how much remaining time we have */
-    timeout_ms = data->set.timeout - /* timeout time */
+    timeout2_ms = data->set.timeout - /* timeout time */
       Curl_tvdiff(Curl_tvnow(), conn->now); /* spent time */
-  else
-    /* Without a requested timeout, we only wait 'response_time' seconds for
-       the full response to arrive before we bail out */
-    timeout_ms = pp->response_time -
-      Curl_tvdiff(Curl_tvnow(), pp->response); /* spent time */
+
+    /* pick the lowest number */
+    timeout_ms = CURLMIN(timeout_ms, timeout2_ms);
+  }
 
   return timeout_ms;
 }
index 2587934cf86068506d5e83ce5e6d40c957354e08..f7757f057dff638e3e4746b042666df10459c0b0 100644 (file)
@@ -637,7 +637,7 @@ static CURLcode smtp_init(struct connectdata *conn)
  * a part of the easy interface, it will always be TRUE.
  */
 static CURLcode smtp_connect(struct connectdata *conn,
-                                 bool *done) /* see description above */
+                             bool *done) /* see description above */
 {
   CURLcode result;
   struct smtp_conn *smtpc = &conn->proto.smtpc;
@@ -784,6 +784,10 @@ static CURLcode smtp_done(struct connectdata *conn, CURLcode status,
 
 
   if(status == CURLE_OK) {
+    struct smtp_conn *smtpc = &conn->proto.smtpc;
+    struct pingpong *pp= &smtpc->pp;
+    pp->response = Curl_tvnow(); /* timeout relative now */
+
     state(conn, SMTP_POSTDATA);
     /* run the state-machine