mirror of https://github.com/schoebel/mars
infra: fix delay computation in limiter
This commit is contained in:
parent
fd30cd6b44
commit
eb9aebc3ae
|
@ -55,9 +55,9 @@ int mars_limit(struct mars_limiter *lim, int amount)
|
||||||
|
|
||||||
// limit exceeded?
|
// limit exceeded?
|
||||||
if (lim->lim_max_rate > 0 && rate > lim->lim_max_rate) {
|
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
|
// compute maximum
|
||||||
if (this_delay > delay)
|
if (this_delay > delay && this_delay > 0)
|
||||||
delay = this_delay;
|
delay = this_delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue