summaryrefslogtreecommitdiff
path: root/src/common/token_bucket.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/token_bucket.c')
-rw-r--r--src/common/token_bucket.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/common/token_bucket.c b/src/common/token_bucket.c
index abb0501833..6af2982147 100644
--- a/src/common/token_bucket.c
+++ b/src/common/token_bucket.c
@@ -120,6 +120,14 @@ token_bucket_refill(token_bucket_t *bucket,
uint32_t now_ts)
{
const uint32_t elapsed_ticks = (now_ts - bucket->last_refilled_at_ts);
+ if (elapsed_ticks > UINT32_MAX-(300*1000)) {
+ /* Either about 48 days have passed since the last refill, or the
+ * monotonic clock has somehow moved backwards. (We're looking at you,
+ * Windows.). We accept up to a 5 minute jump backwards as
+ * "unremarkable".
+ */
+ return 0;
+ }
const uint32_t elapsed_steps = elapsed_ticks / TICKS_PER_STEP;
if (!elapsed_steps) {