mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-22 22:03:43 +03:00
ratelimit: add ratelimit_left helper
(cherry picked from commit 53d6987f9e46927bbc9ad683c091c070ebe06658)
This commit is contained in:
parent
604d132fde
commit
6ca461fe29
@ -49,3 +49,12 @@ usec_t ratelimit_end(const RateLimit *rl) {
|
||||
|
||||
return usec_add(rl->begin, rl->interval);
|
||||
}
|
||||
|
||||
usec_t ratelimit_left(const RateLimit *rl) {
|
||||
assert(rl);
|
||||
|
||||
if (rl->begin == 0)
|
||||
return 0;
|
||||
|
||||
return usec_sub_unsigned(ratelimit_end(rl), now(CLOCK_MONOTONIC));
|
||||
}
|
||||
|
@ -25,3 +25,4 @@ bool ratelimit_below(RateLimit *r);
|
||||
unsigned ratelimit_num_dropped(RateLimit *r);
|
||||
|
||||
usec_t ratelimit_end(const RateLimit *rl);
|
||||
usec_t ratelimit_left(const RateLimit *rl);
|
||||
|
Loading…
x
Reference in New Issue
Block a user