Fix #61: Reassert net/* conditions after initctl reload

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2017-01-16 01:09:06 +01:00
parent 0cccc629bf
commit 044ded3045
3 changed files with 38 additions and 0 deletions
+29
View File
@@ -21,6 +21,7 @@
* THE SOFTWARE.
*/
#include <ftw.h>
#include <libgen.h>
#include <lite/lite.h>
#include <stdio.h>
@@ -124,6 +125,34 @@ void cond_reload(void)
cond_update(NULL);
}
static int reassert(const char *fpath, const struct stat *UNUSED(sb), int tflg, struct FTW *ftw)
{
char *nm;
if (ftw->level == 0)
return 1;
if (tflg != FTW_F)
return 0;
nm = (char *)fpath + sizeof(COND_PATH);
_d("Reasserting %s => %s", fpath, nm);
cond_set(nm);
return 0;
}
/*
* Used only by netlink plugin atm.
* type: is a one of svc/, net/, etc.
*/
void cond_reassert(const char *type)
{
_d("%s", type);
nftw(cond_path(type), reassert, 20, FTW_DEPTH);
}
/**
* Local Variables:
* indent-tabs-mode: t
+1
View File
@@ -24,6 +24,7 @@ int cond_set_path(const char *path, enum cond_state new);
void cond_set (const char *name);
void cond_clear (const char *name);
void cond_reload (void);
void cond_reassert(const char *pat);
#endif /* FINIT_COND_H_ */
+8
View File
@@ -186,8 +186,16 @@ static void nl_callback(void *UNUSED(arg), int sd, int UNUSED(events))
}
}
static void nl_reconf(void *_null)
{
(void)_null;
cond_reassert("net/");
}
static plugin_t plugin = {
.name = __FILE__,
.hook[HOOK_SVC_RECONF] = { .cb = nl_reconf },
.io = {
.cb = nl_callback,
.flags = PLUGIN_IO_READ,