From 7f937bfa94b630afc97d973f1fc15bf63052e4d5 Mon Sep 17 00:00:00 2001
From: Da-Yoon Chung <dayoonc@andrew.cmu.edu>
Date: Mon, 6 Apr 2015 13:22:07 -0400
Subject: [PATCH] lib/transfer.c: Remove factor of 8 from sleep time
 calculation

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
---
 lib/transfer.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/transfer.c b/lib/transfer.c
index ed358dc..267e0a1 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -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.
-- 
1.7.9.5

