mirror of
https://github.com/troglobit/finit.git
synced 2026-10-02 05:52:48 +07:00
devmon: re-evaluate device conditions on reconf
Device conditions tracked by devmon were lost on `initctl reload` because the reconf path did not re-assert them. Add devmon_reconf() to iterate all tracked device nodes and set or clear their conditions based on current device presence. Signed-off-by: Mattias Walström <lazzer@gmail.com>
This commit is contained in:
@@ -113,6 +113,20 @@ void devmon_del_cond(const char *cond)
|
||||
drop_node(find_node(cond));
|
||||
}
|
||||
|
||||
void devmon_reconf(void)
|
||||
{
|
||||
struct dev_node *node, *tmp;
|
||||
char path[PATH_MAX];
|
||||
|
||||
TAILQ_FOREACH_SAFE(node, &dev_node_list, link, tmp) {
|
||||
snprintf(path, sizeof(path), "/%s", node->name);
|
||||
if (fexist(path))
|
||||
cond_set(node->name);
|
||||
else
|
||||
cond_clear(node->name);
|
||||
}
|
||||
}
|
||||
|
||||
static int devmon_add_path(struct iwatch *iw, char *path)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
void devmon_add_cond(const char *cond);
|
||||
void devmon_del_cond(const char *cond);
|
||||
|
||||
void devmon_reconf(void);
|
||||
void devmon_init(uev_ctx_t *ctx);
|
||||
|
||||
#endif /* FINIT_DEVMON_H_ */
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "cgroup.h"
|
||||
#include "cond.h"
|
||||
#include "conf.h"
|
||||
#include "devmon.h"
|
||||
#include "log.h"
|
||||
#include "helpers.h"
|
||||
#include "private.h"
|
||||
@@ -515,6 +516,9 @@ restart:
|
||||
dbg("Calling reconf hooks ...");
|
||||
plugin_run_hooks(HOOK_SVC_RECONF);
|
||||
|
||||
dbg("Update configuration generation of device conditions ...");
|
||||
devmon_reconf();
|
||||
|
||||
dbg("Update configuration generation of unmodified non-native services ...");
|
||||
service_notify_reconf();
|
||||
|
||||
|
||||
@@ -42,6 +42,11 @@ test_one()
|
||||
|
||||
mkdev "$node"
|
||||
assert_status "serv" "running"
|
||||
assert_cond "$cond"
|
||||
|
||||
run "initctl reload"
|
||||
assert_status "serv" "running"
|
||||
assert_cond "$cond"
|
||||
|
||||
rmdev "$node"
|
||||
assert_status "serv" "waiting"
|
||||
|
||||
Reference in New Issue
Block a user