diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-01-29 04:42:57 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-01-29 04:42:57 +0100 |
commit | 1e2e81336b2d7691d51a6f3e82df9ae20c22aee1 (patch) | |
tree | eedbc1b5b0d24efcc6437f987efa4fbdf9b5a986 /service.c | |
parent | c20cae324d93e7fcdb8618e37c3ac377d87edb97 (diff) |
ratelimit start requests
Diffstat (limited to 'service.c')
-rw-r--r-- | service.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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; |