mirror of
https://github.com/troglobit/finit.git
synced 2026-12-04 21:58:19 +00: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:
1 parent
11e02fabb3
commit
f217794773
1 file changed
+12
-1
+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)
|
static int do_delete(const char *fpath, const struct stat *sb, int tflag, struct FTW *ftw)
|
||||||
{
|
{
|
||||||
|
const char *cond, *ptr;
|
||||||
|
|
||||||
if (ftw->level == 0)
|
if (ftw->level == 0)
|
||||||
return 1;
|
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))
|
if (remove(fpath))
|
||||||
err(1, "Failed removing condition %s", fpath);
|
err(1, "Failed removing condition %s", fpath);
|
||||||
|
|
||||||
|
cond = ptr + strlen(COND_BASE) + 1;
|
||||||
|
cond_update(cond);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cond_delpath(const char *path)
|
static void cond_delpath(const char *path)
|
||||||
{
|
{
|
||||||
nftw(path, do_delete, 20, FTW_DEPTH);
|
nftw(path, do_delete, 20, FTW_DEPTH);
|
||||||
if (remove(path))
|
if (remove(path) && errno != ENOENT)
|
||||||
err(1, "Failed removing condition path %s", path);
|
err(1, "Failed removing condition path %s", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user