Skip to content

Commit c221823

Browse files
committed
shutdown: use cond_clear_noupdate() to prevent nested service_stop()
When the system shuts down, or user changes runlevels, we don't have to call cond_clear_update(), because this can lead to nested service_stop() calls, which in turn lead to out of sync progress updates: [ .. ] Stopping Foo [ OK ] Stopping Bar [ OK ] Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
1 parent 248f7d3 commit c221823

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/cond-w.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "cond.h"
3636
#include "pid.h"
3737
#include "service.h"
38+
#include "sm.h"
3839

3940
struct cond_boot {
4041
TAILQ_ENTRY(cond_boot) link;
@@ -214,7 +215,10 @@ static int do_delete(const char *fpath, const struct stat *sb, int tflag, struct
214215
err(1, "Failed removing condition %s", fpath);
215216

216217
cond = ptr + strlen(COND_BASE) + 1;
217-
cond_update(cond);
218+
if (sm_is_in_teardown(&sm))
219+
cond_clear_noupdate(cond);
220+
else
221+
cond_update(cond);
218222

219223
return 0;
220224
}

src/service.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2261,7 +2261,7 @@ static void svc_set_state(svc_t *svc, svc_state_t new_state)
22612261
/* if PID isn't collected within SVC_TERM_TIMEOUT msec, kill it! */
22622262
if (new_state == SVC_STOPPING_STATE) {
22632263
dbg("%s is stopping, wait %d sec before sending SIGKILL ...",
2264-
svc_ident(svc, NULL, 0), svc->killdelay / 1000);
2264+
svc_ident(svc, NULL, 0), svc->killdelay / 1000);
22652265
service_timeout_cancel(svc);
22662266
service_timeout_after(svc, svc->killdelay, service_kill);
22672267
}
@@ -2299,6 +2299,8 @@ static void svc_set_state(svc_t *svc, svc_state_t new_state)
22992299
if ((old_state == SVC_RUNNING_STATE && new_state == SVC_PAUSED_STATE) ||
23002300
(old_state == SVC_PAUSED_STATE && new_state == SVC_RUNNING_STATE))
23012301
; /* only paused during reload, don't clear conds. */
2302+
else if (sm_is_in_teardown(&sm))
2303+
cond_clear_noupdate(cond);
23022304
else
23032305
cond_clear(cond);
23042306

0 commit comments

Comments
 (0)