fix: timeout after last data chunk was handled
authorBob Richmond <bob.richmond@ticketmaster.com>
Wed, 24 Mar 2010 16:02:17 +0000 (17:02 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 24 Mar 2010 16:02:17 +0000 (17:02 +0100)
Bob Richmond: There's an annoying situation where libcurl will
read new HTTP response data from a socket, then check if it's a
timeout if one is set. If the last packet received constitutes
the end of the response body, libcurl still treats it as a
timeout condition and reports a message like:

"Operation timed out after 3000 milliseconds with 876 out of 876
bytes received"

It should only a timeout if the timer lapsed and we DIDN'T
receive the end of the response body yet.

CHANGES
RELEASE-NOTES
lib/transfer.c

diff --git a/CHANGES b/CHANGES
index b6a5d42..fa3f400 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,17 @@
                                   Changelog
 
 Daniel Stenberg (24 Mar 2010)
+- Bob Richmond: There's an annoying situation where libcurl will read new HTTP
+  response data from a socket, then check if it's a timeout if one is set. If
+  the last packet received constitutes the end of the response body, libcurl
+  still treats it as a timeout condition and reports a message like:
+
+  "Operation timed out after 3000 milliseconds with 876 out of 876 bytes 
+  received"
+
+  It should only a timeout if the timer lapsed and we DIDN'T receive the end
+  of the response body yet.
+
 - Christopher Conroy fixed a problem with RTSP and GET_PARAMETER reported
   to us by Massimo Callegari. There's a new test case 572 that verifies this
   now.
index 9c6775f..b213402 100644 (file)
@@ -40,6 +40,7 @@ This release includes the following bugfixes:
  o chunked-encoding with Content-Length: header problem
  o multi interface HTTP POST over a proxy using PROXYTUNNEL
  o RTSP GET_PARAMETER
+ o timeout after last data chunk was handled
 
 This release includes the following known bugs:
 
@@ -52,6 +53,7 @@ advice from friends like these:
  Daniel Fandrich, Patrick Monnerat, Pat Ray, Wesley Miaw, Ben Greear,
  Ryan Chan, Markus Duft, Andrei Benea, Jacob Moshenko, Daniel Johnson,
  Constantine Sapuntzakis, Douglas Steinwand, Thomas Lopatic, Hauke Duden,
- Akos Pasztory, Kenny To, Christopher Conroy, Massimo Callegari
+ Akos Pasztory, Kenny To, Christopher Conroy, Massimo Callegari,
+ Bob Richmond
 
         Thanks! (and sorry if I forgot to mention someone)
index 6e669ab..ad9499c 100644 (file)
@@ -1060,21 +1060,22 @@ CURLcode Curl_readwrite(struct connectdata *conn,
   if(result)
     return result;
 
-  if(data->set.timeout &&
-     (Curl_tvdiff(k->now, k->start) >= data->set.timeout)) {
-    if(k->size != -1) {
-      failf(data, "Operation timed out after %ld milliseconds with %"
-            FORMAT_OFF_T " out of %" FORMAT_OFF_T " bytes received",
-            Curl_tvdiff(k->now, k->start), k->bytecount, k->size);
-    } else {
-      failf(data, "Operation timed out after %ld milliseconds with %"
-            FORMAT_OFF_T " bytes received",
-            Curl_tvdiff(k->now, k->start), k->bytecount);
+  if(k->keepon) {
+    if(data->set.timeout &&
+       (Curl_tvdiff(k->now, k->start) >= data->set.timeout)) {
+      if(k->size != -1) {
+        failf(data, "Operation timed out after %ld milliseconds with %"
+              FORMAT_OFF_T " out of %" FORMAT_OFF_T " bytes received",
+              Curl_tvdiff(k->now, k->start), k->bytecount, k->size);
+      } else {
+        failf(data, "Operation timed out after %ld milliseconds with %"
+              FORMAT_OFF_T " bytes received",
+              Curl_tvdiff(k->now, k->start), k->bytecount);
+      }
+      return CURLE_OPERATION_TIMEDOUT;
     }
-    return CURLE_OPERATION_TIMEDOUT;
   }
-
-  if(!k->keepon) {
+  else {
     /*
      * The transfer has been performed. Just make some general checks before
      * returning.