From f217794773184e9fd0f1a8a57bc022b4abb74207 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Tue, 15 Nov 2022 09:24:54 +0100 Subject: [PATCH] Fix #314: call cond_update() also when removing all service/foo/* When removing a whole tree of conditions we need to walk through each and call cond_update() to ensure that all dependant tasks are stopped and put back in waiting. Signed-off-by: Joachim Wiberg --- src/cond-w.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/cond-w.c b/src/cond-w.c index 889beaa0..acd6b2fb 100644 --- a/src/cond-w.c +++ b/src/cond-w.c @@ -196,19 +196,30 @@ static int cond_checkpath(const char *path) static int do_delete(const char *fpath, const struct stat *sb, int tflag, struct FTW *ftw) { + const char *cond, *ptr; + if (ftw->level == 0) return 1; + ptr = strstr(fpath, COND_BASE); + if (!ptr) { + warnx("%s does not seem to be a Finit condition, skipping", fpath); + return 0; + } + if (remove(fpath)) err(1, "Failed removing condition %s", fpath); + cond = ptr + strlen(COND_BASE) + 1; + cond_update(cond); + return 0; } static void cond_delpath(const char *path) { nftw(path, do_delete, 20, FTW_DEPTH); - if (remove(path)) + if (remove(path) && errno != ENOENT) err(1, "Failed removing condition path %s", path); }