Browse Source

Never pick a rate of 0.

(The tests caught this one.)
Nick Mathewson 6 years ago
parent
commit
9c405ba595
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/common/token_bucket.c

+ 2 - 1
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;
 }
 
 /**