]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/ratelimit.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 This file is part of systemd.
5 Copyright 2010 Lennart Poettering
12 #include "ratelimit.h"
14 /* Modelled after Linux' lib/ratelimit.c by Dave Young
15 * <hidave.darkstar@gmail.com>, which is licensed GPLv2. */
17 bool ratelimit_test(RateLimit
*r
) {
22 if (r
->interval
<= 0 || r
->burst
<= 0)
25 ts
= now(CLOCK_MONOTONIC
);
28 r
->begin
+ r
->interval
< ts
) {
36 if (r
->num
< r
->burst
)