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 | |
parent | 82c64bf578623f0678b4de1ac08c6bd8e5d95662 (diff) |
service: allow immediate stopping while starting
Diffstat (limited to 'src')
-rw-r--r-- | src/mount.c | 19 | ||||
-rw-r--r-- | src/service.c | 25 | ||||
-rw-r--r-- | src/socket.c | 16 |
3 files changed, 32 insertions, 28 deletions
diff --git a/src/mount.c b/src/mount.c index bff956e166..30390de99d 100644 --- a/src/mount.c +++ b/src/mount.c @@ -806,23 +806,20 @@ static int mount_stop(Unit *u) { assert(m); - /* Cann't do this right now. */ - if (m->state == MOUNT_MOUNTING || - m->state == MOUNT_MOUNTING_DONE || - m->state == MOUNT_MOUNTING_SIGTERM || - m->state == MOUNT_MOUNTING_SIGKILL || - m->state == MOUNT_REMOUNTING || - m->state == MOUNT_REMOUNTING_SIGTERM || - m->state == MOUNT_REMOUNTING_SIGKILL) - return -EAGAIN; - /* Already on it */ if (m->state == MOUNT_UNMOUNTING || m->state == MOUNT_UNMOUNTING_SIGKILL || m->state == MOUNT_UNMOUNTING_SIGTERM) return 0; - assert(m->state == MOUNT_MOUNTED); + assert(m->state == MOUNT_MOUNTING || + m->state == MOUNT_MOUNTING_DONE || + m->state == MOUNT_MOUNTED || + m->state == MOUNT_MOUNTING_SIGTERM || + m->state == MOUNT_MOUNTING_SIGKILL || + m->state == MOUNT_REMOUNTING || + m->state == MOUNT_REMOUNTING_SIGTERM || + m->state == MOUNT_REMOUNTING_SIGKILL); mount_enter_unmounting(m, true); return 0; 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; diff --git a/src/socket.c b/src/socket.c index 6cbb14137e..7ff2927aff 100644 --- a/src/socket.c +++ b/src/socket.c @@ -1166,21 +1166,23 @@ static int socket_stop(Unit *u) { assert(s); - /* We cannot fulfill this request right now, try again later - * please! */ - if (s->state == SOCKET_START_PRE || - s->state == SOCKET_START_POST) - return -EAGAIN; - /* Already on it */ if (s->state == SOCKET_STOP_PRE || s->state == SOCKET_STOP_PRE_SIGTERM || s->state == SOCKET_STOP_PRE_SIGKILL || s->state == SOCKET_STOP_POST || s->state == SOCKET_FINAL_SIGTERM || - s->state == SOCKET_FINAL_SIGTERM) + s->state == SOCKET_FINAL_SIGKILL) return 0; + /* If there's already something running we go directly into + * kill mode. */ + if (s->state == SOCKET_START_PRE || + s->state == SOCKET_START_POST) { + socket_enter_signal(s, SOCKET_STOP_PRE_SIGTERM, true); + return -EAGAIN; + } + assert(s->state == SOCKET_LISTENING || s->state == SOCKET_RUNNING); socket_enter_stop_pre(s, true); |