When downloading multiple files in a row without resetting the CURL options and limiting download speed using CURLOPT_MAX_RECV_SPEED_LARGE, only the first file downloaded will be rate-limited. Subsequent files will download as fast as possible.
After checking this on a few versions, doing some printf debugging, and scanning through recent pull requests, it seems to be the issue was introduced in 7.60 with this commit. Curl_pgrsLimitWaitTime() uses progress.downloaded and progress.dl_limit_size with Curl_ratelimit(), but progress.dl_limit_size doesn't get reset after the transfer ends, so when the second file is downloaded, Curl_pgrsLimitWaitTime() ends up calculating weird negative values that clearly seem unintended and the function returns 0, so no rate limiting occurs.
to Curl_pgrsStartNow(), then the problem goes away because the call to Curl_ratelimit then resets dl_limit_size, but I'm not familiar enough with the rest of the codebase to know if this is the best way to solve the problem or whether or not it could cause other problems.
Problem also exists when using CURLOPT_MAX_SEND_SPEED_LARGE in the same way.
The text was updated successfully, but these errors were encountered: