diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-07-10 04:52:00 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-07-10 04:52:00 +0200 |
commit | 3f6c78dcebdc0904d3b614da07e9ec8d84de2532 (patch) | |
tree | 71dd11b3f29bb6341270fec2e0afe0fdf8dc96be /src/service.c | |
parent | 82c64bf578623f0678b4de1ac08c6bd8e5d95662 (diff) |
service: allow immediate stopping while starting
Diffstat (limited to 'src/service.c')
-rw-r--r-- | src/service.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/service.c b/src/service.c index fc773d20eb..b837cb81e5 100644 --- a/src/service.c +++ b/src/service.c @@ -1902,12 +1902,9 @@ static int service_stop(Unit *u) { assert(s); - /* Cannot do this now */ - if (s->state == SERVICE_START_PRE || - s->state == SERVICE_START || - s->state == SERVICE_START_POST || - s->state == SERVICE_RELOAD) - return -EAGAIN; + /* This is a user request, so don't do restarts on this + * shutdown. */ + s->allow_restart = false; /* Already on it */ if (s->state == SERVICE_STOP || @@ -1918,16 +1915,24 @@ static int service_stop(Unit *u) { s->state == SERVICE_FINAL_SIGKILL) return 0; + /* Don't allow a restart */ if (s->state == SERVICE_AUTO_RESTART) { service_set_state(s, SERVICE_DEAD); return 0; } - assert(s->state == SERVICE_RUNNING || s->state == SERVICE_EXITED); + /* If there's already something running we go directly into + * kill mode. */ + if (s->state == SERVICE_START_PRE || + s->state == SERVICE_START || + s->state == SERVICE_START_POST || + s->state == SERVICE_RELOAD) { + service_enter_signal(s, SERVICE_STOP_SIGTERM, true); + return 0; + } - /* This is a user request, so don't do restarts on this - * shutdown. */ - s->allow_restart = false; + assert(s->state == SERVICE_RUNNING || + s->state == SERVICE_EXITED); service_enter_stop(s, true); return 0; |