]>
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
11 #include "ratelimit.h"
13 /* Modelled after Linux' lib/ratelimit.c by Dave Young
14 * <hidave.darkstar@gmail.com>, which is licensed GPLv2. */
16 bool ratelimit_test(RateLimit
*r
) {
21 if (r
->interval
<= 0 || r
->burst
<= 0)
24 ts
= now(CLOCK_MONOTONIC
);
27 r
->begin
+ r
->interval
< ts
) {
35 if (r
->num
< r
->burst
)