mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07:00
Fix #61: Reassert net/* conditions after initctl reload
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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_ */
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user