]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
transfer: avoid busy loop with tiny speed limit
authorStefan Eissing <stefan@eissing.org>
Thu, 25 Sep 2025 11:25:29 +0000 (13:25 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 25 Sep 2025 12:18:35 +0000 (14:18 +0200)
When a transfer has a speed limit less than 4, the receive loop early
exits without receiving anything, causing a busy loop for that transfer.

Perform that check only after the first receive has been done.

Reported in Joshua's sarif data

Closes #18732

lib/transfer.c

index 1297a3e82d26928a6427a74111a8b419f4ee64ac..62528d2275770ce67ca9908f7206246a567ba219 100644 (file)
@@ -283,7 +283,7 @@ static CURLcode sendrecv_dl(struct Curl_easy *data,
        * a quarter of the quota, break out. We want to stutter a bit
        * to keep in the limit, but too small receives will just cost
        * cpu unnecessarily. */
-      if(total_received >= (data->set.max_recv_speed / 4))
+      if(total_received && (total_received >= (data->set.max_recv_speed / 4)))
         break;
       if(data->set.max_recv_speed < (curl_off_t)bytestoread)
         bytestoread = (size_t)data->set.max_recv_speed;