[systemd-devel] [PATCH] ratelimit: fix off-by-one
Michael Olbrich
m.olbrich at pengutronix.de
Tue Feb 12 23:00:46 PST 2013
The current code might make sense during startup for service restart
limiting:
With burst=1 after starting num is 1, so the next ('first') restart is
still accepted ( 1 <= 1). However, once interval has expired, num is 1
after the first restart, so the second restart is also accepted.
This change is also useful in combination with watchdogs:
With burst=1 and a very large interval the system can be restarted on
the first failure.
---
src/shared/ratelimit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/shared/ratelimit.c b/src/shared/ratelimit.c
index 1054d52..01b62b7 100644
--- a/src/shared/ratelimit.c
+++ b/src/shared/ratelimit.c
@@ -46,7 +46,7 @@ bool ratelimit_test(RateLimit *r) {
goto good;
}
- if (r->num <= r->burst)
+ if (r->num < r->burst)
goto good;
return false;
--
1.7.10.4
More information about the systemd-devel
mailing list