]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
multi: during ratelimit multi_getsock should return no sockets
authorDaniel Stenberg <daniel@haxx.se>
Thu, 30 Nov 2023 09:32:16 +0000 (10:32 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 30 Nov 2023 14:53:22 +0000 (15:53 +0100)
... as there is nothing to wait for then, it just waits. Otherwise, this
causes much more CPU work and updates than necessary during ratelimit
periods.

Ref: https://curl.se/mail/lib-2023-11/0056.html
Closes #12430

lib/multi.c
lib/progress.c

index e62f2376937a251865e66595f448580c1bd33211..5456113be7a497bf68fb5014a216ad10ed415db2 100644 (file)
@@ -1064,6 +1064,10 @@ static void multi_getsock(struct Curl_easy *data,
   case MSTATE_PERFORMING:
     Curl_pollset_add_socks(data, ps, Curl_single_getsock);
     break;
+
+  case MSTATE_RATELIMITING:
+    /* nothing to wait for */
+    return;
   }
 
   /* Let connection filters add/remove as needed */
index b0fc4aa48fdf646bff0fd4803e72b6933962bbda..e96cbf7af4c8da6e65272c27334538b597d9a2dd 100644 (file)
@@ -304,7 +304,7 @@ timediff_t Curl_pgrsLimitWaitTime(curl_off_t cursize,
    * 'actual' is the time in milliseconds it took to actually download the
    * last 'size' bytes.
    */
-  actual = Curl_timediff(now, start);
+  actual = Curl_timediff_ceil(now, start);
   if(actual < minimum) {
     /* if it downloaded the data faster than the limit, make it wait the
        difference */