1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-26 03:22:00 +03:00

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:
Lennart Poettering 2020-10-08 18:40:35 +02:00
parent 15c689d77f
commit 2a155c53ab
2 changed files with 5 additions and 1 deletions

View File

@ -13,7 +13,7 @@ bool ratelimit_below(RateLimit *r) {
assert(r);
if (r->interval <= 0 || r->burst <= 0)
if (!ratelimit_configured(r))
return true;
ts = now(CLOCK_MONOTONIC);

View File

@ -17,4 +17,8 @@ static inline void ratelimit_reset(RateLimit *rl) {
rl->num = rl->begin = 0;
}
static inline bool ratelimit_configured(RateLimit *rl) {
return rl->interval > 0 && rl->burst > 0;
}
bool ratelimit_below(RateLimit *r);