ratelimit: add ratelimit_configured() helper
This helper alone doesn't make too much sense, but it's preparatory work for #17274, and I guess it can't hurt to land it early, it does make the ratelimit code a tiny bit prettier after all.
This commit is contained in:
parent
15c689d77f
commit
2a155c53ab
|
@ -13,7 +13,7 @@ bool ratelimit_below(RateLimit *r) {
|
||||||
|
|
||||||
assert(r);
|
assert(r);
|
||||||
|
|
||||||
if (r->interval <= 0 || r->burst <= 0)
|
if (!ratelimit_configured(r))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
ts = now(CLOCK_MONOTONIC);
|
ts = now(CLOCK_MONOTONIC);
|
||||||
|
|
|
@ -17,4 +17,8 @@ static inline void ratelimit_reset(RateLimit *rl) {
|
||||||
rl->num = rl->begin = 0;
|
rl->num = rl->begin = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool ratelimit_configured(RateLimit *rl) {
|
||||||
|
return rl->interval > 0 && rl->burst > 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool ratelimit_below(RateLimit *r);
|
bool ratelimit_below(RateLimit *r);
|
||||||
|
|
Loading…
Reference in a new issue