mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07:00
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 <troglobit@gmail.com>
This commit is contained in:
+12
-1
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user