1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 19:21:53 +03:00

ratelimit: fix off-by-one

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.
This commit is contained in:
Michael Olbrich 2013-02-13 08:00:46 +01:00 committed by Zbigniew Jędrzejewski-Szmek
parent a3aa7ee6ff
commit 1c00832624

View File

@ -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;