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>
This commit is contained in:
Joachim Wiberg committed 2024-02-03 17:31:37 +01:00
1 parent 248f7d3110
commit c221823654
2 files changed
+6

No files matched your search

+4
View File
@@ -35,6 +35,7 @@
#include "cond.h" #include "cond.h"
#include "pid.h" #include "pid.h"
#include "service.h" #include "service.h"
#include "sm.h"
struct cond_boot { struct cond_boot {
TAILQ_ENTRY(cond_boot) link; TAILQ_ENTRY(cond_boot) link;
@@ -214,6 +215,9 @@ static int do_delete(const char *fpath, const struct stat *sb, int tflag, struct
err(1, "Failed removing condition %s", fpath); err(1, "Failed removing condition %s", fpath);
cond = ptr + strlen(COND_BASE) + 1; cond = ptr + strlen(COND_BASE) + 1;
if (sm_is_in_teardown(&sm))
cond_clear_noupdate(cond);
else
cond_update(cond); cond_update(cond);
return 0; return 0;
+2
View File
@@ -2299,6 +2299,8 @@ static void svc_set_state(svc_t *svc, svc_state_t new_state)
if ((old_state == SVC_RUNNING_STATE && new_state == SVC_PAUSED_STATE) || if ((old_state == SVC_RUNNING_STATE && new_state == SVC_PAUSED_STATE) ||
(old_state == SVC_PAUSED_STATE && new_state == SVC_RUNNING_STATE)) (old_state == SVC_PAUSED_STATE && new_state == SVC_RUNNING_STATE))
; /* only paused during reload, don't clear conds. */ ; /* only paused during reload, don't clear conds. */
else if (sm_is_in_teardown(&sm))
cond_clear_noupdate(cond);
else else
cond_clear(cond); cond_clear(cond);