Skip to content

Commit

Permalink
lib/transfer.c: Remove factor of 8 from sleep time calculation
Browse files Browse the repository at this point in the history
The factor of 8 is a bytes-to-bits conversion factor, but pkt_size and
rate_bps are both in bytes. When using the rate limiting option, curl
waits 8 times too long, and then transfers very quickly until the
average rate reaches the limit. The average rate follows the limit over
time, but the actual traffic is bursty.

Thanks-to: Benjamin Gilbert
  • Loading branch information
dayoonc authored and bagder committed Apr 7, 2015
1 parent c3101ae commit a9e4674
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/transfer.c
Expand Up @@ -1270,7 +1270,7 @@ long Curl_sleep_time(curl_off_t rate_bps, curl_off_t cur_rate_bps,
* the next packet at the adjusted rate. We should wait
* longer when using larger packets, for instance.
*/
rv = ((curl_off_t)((pkt_size * 8) * 1000) / rate_bps);
rv = ((curl_off_t)(pkt_size * 1000) / rate_bps);

/* Catch rounding errors and always slow down at least 1ms if
* we are running too fast.
Expand Down

0 comments on commit a9e4674

Please sign in to comment.