summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-07-18 02:28:08 +0200
committerLennart Poettering <lennart@poettering.net>2012-07-18 02:28:08 +0200
commita8bb2e6503fa2a4ed608aa958480d27a696f5146 (patch)
tree5d87911bb29bc839db76a3837c53b1e5b595e8c7 /src/core
parent6b78f9b4354010f8af2fe48c783ffd52b2db8f57 (diff)
service: make start jobs wait, not fail, when an automatic restart is queued
When an automatic restart is already queued, then make subsequent start jobs wait until the restart can be handled (i.e. after the holdhoff time), instead of simply fail.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/service.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/core/service.c b/src/core/service.c
index 7a7e25ffcd..cf480ab979 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -2258,10 +2258,12 @@ static void service_enter_restart(Service *s) {
assert(s);
dbus_error_init(&error);
- if (UNIT(s)->job) {
- log_info("Job pending for unit, delaying automatic restart.");
+ if (UNIT(s)->job && UNIT(s)->job->type == JOB_STOP) {
+ /* Don't restart things if we are going down anyway */
+ log_info("Stop job pending for unit, delaying automatic restart.");
- if ((r = unit_watch_timer(UNIT(s), s->restart_usec, &s->timer_watch)) < 0)
+ r = unit_watch_timer(UNIT(s), s->restart_usec, &s->timer_watch);
+ if (r < 0)
goto fail;
return;
@@ -2275,6 +2277,10 @@ static void service_enter_restart(Service *s) {
if (r < 0)
goto fail;
+ /* Note that we stay in the SERVICE_AUTO_RESTART state here,
+ * it will be canceled as part of the service_stop() call that
+ * is executed as part of JOB_RESTART. */
+
log_debug("%s scheduled restart job.", UNIT(s)->id);
return;
@@ -2473,7 +2479,7 @@ static int service_start(Unit *u) {
* service should be manually restarted, not started. */
if (s->state == SERVICE_AUTO_RESTART) {
log_warning("%s automatic restart is pending, must be stopped before issuing start request.", UNIT(s)->id);
- return -ECANCELED;
+ return -EAGAIN;
}
assert(s->state == SERVICE_DEAD || s->state == SERVICE_FAILED);