summaryrefslogtreecommitdiff
path: root/service.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-01-29 04:42:57 +0100
committerLennart Poettering <lennart@poettering.net>2010-01-29 04:42:57 +0100
commit1e2e81336b2d7691d51a6f3e82df9ae20c22aee1 (patch)
treeeedbc1b5b0d24efcc6437f987efa4fbdf9b5a986 /service.c
parentc20cae324d93e7fcdb8618e37c3ac377d87edb97 (diff)
ratelimit start requests
Diffstat (limited to 'service.c')
-rw-r--r--service.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/service.c b/service.c
index 70299dd065..2943da6e80 100644
--- a/service.c
+++ b/service.c
@@ -100,6 +100,8 @@ static int service_init(Unit *u) {
s->state = SERVICE_DEAD;
+ RATELIMIT_INIT(s->ratelimit, 10*USEC_PER_SEC, 5);
+
/* Load a .service file */
if ((r = unit_load_fragment(u)) < 0) {
service_done(u);
@@ -734,6 +736,12 @@ static int service_start(Unit *u) {
assert(s->state == SERVICE_DEAD || s->state == SERVICE_MAINTAINANCE || s->state == SERVICE_AUTO_RESTART);
+ /* Make sure we don't enter a busy loop of some kind. */
+ if (!ratelimit_test(&s->ratelimit)) {
+ log_warning("%s start request repeated too quickly, refusing to start.", unit_id(u));
+ return -EAGAIN;
+ }
+
s->failure = false;
s->main_pid_known = false;