Fix 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.
@@ -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);
}
