multi_runsingle: CURLOPT_LOW_SPEED_* fix for rate limitation
authorDaniel Stenberg <daniel@haxx.se>
Mon, 1 Oct 2012 22:16:20 +0000 (00:16 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 1 Oct 2012 22:16:20 +0000 (00:16 +0200)
During the periods of rate limitation, the speedcheck function wasn't
called and thus the values weren't updated accordingly and it would then
easily trigger wrongly once data got transferred again.

Also, the progress callback's return code was not acknowledged in this
state so it could make an "abort" return code to get ignored and not
have the documented effect of aborting an ongoing transfer.

Bug: http://curl.haxx.se/mail/lib-2012-09/0081.html
Reported by: Jie He

lib/multi.c

index b6c327b77724f77094f9fd8084d666e34a4f9dac..6506b5ee48a8a85865864c3316b1da0c63a78396 100644 (file)
@@ -43,6 +43,7 @@
 #include "http.h"
 #include "select.h"
 #include "warnless.h"
+#include "speedcheck.h"
 
 #define _MPRINTF_REPLACE /* use our functions only */
 #include <curl/mprintf.h>
@@ -1518,7 +1519,11 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
 
     case CURLM_STATE_TOOFAST: /* limit-rate exceeded in either direction */
       /* if both rates are within spec, resume transfer */
-      Curl_pgrsUpdate(easy->easy_conn);
+      if(Curl_pgrsUpdate(easy->easy_conn))
+        easy->result = CURLE_ABORTED_BY_CALLBACK;
+      else
+        easy->result = Curl_speedcheck(data, now);
+
       if(( (data->set.max_send_speed == 0) ||
            (data->progress.ulspeed < data->set.max_send_speed ))  &&
          ( (data->set.max_recv_speed == 0) ||