diff options
| author | Michael Biebl <biebl@debian.org> | 2021-10-01 23:05:04 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2021-10-01 23:05:04 +0200 |
| commit | e74c568b07b50b97873fb4ee1d776dedefbd54d6 (patch) | |
| tree | 3469f17ea9af91f7ff169b890633bda68b0cf76e /shared/systemd/src/basic/ratelimit.c | |
| parent | bfe522304da217296e2a61040f58e35ec5d6f3f2 (diff) | |
New upstream version 1.32.12 upstream/1.32.12
Diffstat (limited to 'shared/systemd/src/basic/ratelimit.c')
| -rw-r--r-- | shared/systemd/src/basic/ratelimit.c | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/shared/systemd/src/basic/ratelimit.c b/shared/systemd/src/basic/ratelimit.c deleted file mode 100644 index 12c8324d..00000000 --- a/shared/systemd/src/basic/ratelimit.c +++ /dev/null @@ -1,40 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ - -#include "nm-sd-adapt-shared.h" - -#include <sys/time.h> - -#include "macro.h" -#include "ratelimit.h" - -/* Modelled after Linux' lib/ratelimit.c by Dave Young - * <hidave.darkstar@gmail.com>, which is licensed GPLv2. */ - -bool ratelimit_below(RateLimit *r) { - usec_t ts; - - assert(r); - - if (!ratelimit_configured(r)) - return true; - - ts = now(CLOCK_MONOTONIC); - - if (r->begin <= 0 || - ts - r->begin > r->interval) { - r->begin = ts; - - /* Reset counter */ - r->num = 0; - goto good; - } - - if (r->num < r->burst) - goto good; - - return false; - -good: - r->num++; - return true; -} |