mirror of
https://github.com/troglobit/finit.git
synced 2026-11-07 16:01:08 +00: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:
4 files changed
+24
No files matched your search
@@ -113,6 +113,20 @@ void devmon_del_cond(const char *cond)
|
|||||||
drop_node(find_node(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)
|
static int devmon_add_path(struct iwatch *iw, char *path)
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
void devmon_add_cond(const char *cond);
|
void devmon_add_cond(const char *cond);
|
||||||
void devmon_del_cond(const char *cond);
|
void devmon_del_cond(const char *cond);
|
||||||
|
|
||||||
|
void devmon_reconf(void);
|
||||||
void devmon_init(uev_ctx_t *ctx);
|
void devmon_init(uev_ctx_t *ctx);
|
||||||
|
|
||||||
#endif /* FINIT_DEVMON_H_ */
|
#endif /* FINIT_DEVMON_H_ */
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "cgroup.h"
|
#include "cgroup.h"
|
||||||
#include "cond.h"
|
#include "cond.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
#include "devmon.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "private.h"
|
#include "private.h"
|
||||||
@@ -515,6 +516,9 @@ restart:
|
|||||||
dbg("Calling reconf hooks ...");
|
dbg("Calling reconf hooks ...");
|
||||||
plugin_run_hooks(HOOK_SVC_RECONF);
|
plugin_run_hooks(HOOK_SVC_RECONF);
|
||||||
|
|
||||||
|
dbg("Update configuration generation of device conditions ...");
|
||||||
|
devmon_reconf();
|
||||||
|
|
||||||
dbg("Update configuration generation of unmodified non-native services ...");
|
dbg("Update configuration generation of unmodified non-native services ...");
|
||||||
service_notify_reconf();
|
service_notify_reconf();
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ test_one()
|
|||||||
|
|
||||||
mkdev "$node"
|
mkdev "$node"
|
||||||
assert_status "serv" "running"
|
assert_status "serv" "running"
|
||||||
|
assert_cond "$cond"
|
||||||
|
|
||||||
|
run "initctl reload"
|
||||||
|
assert_status "serv" "running"
|
||||||
|
assert_cond "$cond"
|
||||||
|
|
||||||
rmdev "$node"
|
rmdev "$node"
|
||||||
assert_status "serv" "waiting"
|
assert_status "serv" "waiting"
|
||||||
|
|||||||
Reference in new issue
Block a user