diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-04-13 11:38:57 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-04-13 16:31:47 -0400 |
commit | 9c405ba59528b931aefc9ed80fed3e5d9f231d27 (patch) | |
tree | 2d78fb3709c014c91173922679b044e6c8c5ef03 /src/common | |
parent | 0b40ed5e70a7200300d63db009a4f2234ff12728 (diff) | |
download | tor-9c405ba59528b931aefc9ed80fed3e5d9f231d27.tar.gz tor-9c405ba59528b931aefc9ed80fed3e5d9f231d27.zip |
Never pick a rate of 0.
(The tests caught this one.)
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/token_bucket.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/common/token_bucket.c b/src/common/token_bucket.c index 1ac1bd6d3c..abfcc680c4 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; } /** |