[tor-commits] [tor/master] Never pick a rate of 0.

nickm at torproject.org nickm at torproject.org
Fri Apr 13 20:44:04 UTC 2018


commit 9c405ba59528b931aefc9ed80fed3e5d9f231d27
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri Apr 13 11:38:57 2018 -0400

    Never pick a rate of 0.
    
    (The tests caught this one.)
---
 src/common/token_bucket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/common/token_bucket.c b/src/common/token_bucket.c
index 1ac1bd6d3..abfcc680c 100644
--- a/src/common/token_bucket.c
+++ b/src/common/token_bucket.c
@@ -76,8 +76,9 @@ rate_per_sec_to_rate_per_step(uint32_t rate)
     (rate / 1000) * to_approximate_msec(TICKS_PER_STEP).  But to minimize
     rounding error, we do it this way instead, and divide last.
   */
-  return (uint32_t)
+  uint32_t val = (uint32_t)
     monotime_coarse_stamp_units_to_approx_msec(rate*TICKS_PER_STEP)/1000;
+  return val ? val : 1;
 }
 
 /**





More information about the tor-commits mailing list