From eb9aebc3ae794756757feb214f41d88f73659fe4 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Wed, 20 Nov 2013 17:17:26 +0100 Subject: [PATCH] infra: fix delay computation in limiter --- kernel/lib_limiter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/lib_limiter.c b/kernel/lib_limiter.c index 8f71017b..b6abb223 100644 --- a/kernel/lib_limiter.c +++ b/kernel/lib_limiter.c @@ -55,9 +55,9 @@ int mars_limit(struct mars_limiter *lim, int amount) // limit exceeded? if (lim->lim_max_rate > 0 && rate > lim->lim_max_rate) { - int this_delay = 1000 - (long long)lim->lim_max_rate * 1000 / rate; + int this_delay = (window * rate / lim->lim_max_rate - window) / (LIMITER_TIME_RESOLUTION / 1000); // compute maximum - if (this_delay > delay) + if (this_delay > delay && this_delay > 0) delay = this_delay; }