mirror of
https://github.com/troglobit/finit.git
synced 2026-10-18 10:59:34 +00:00
Merge pull request #473 from mattiaswal/fix-devmon
This commit is contained in:
4 files changed
+25
-1
No files matched your search
+15
-1
@@ -107,12 +107,26 @@ void devmon_add_cond(const char *cond)
|
||||
|
||||
void devmon_del_cond(const char *cond)
|
||||
{
|
||||
if (!cond || strcmp(cond, "dev/"))
|
||||
if (!cond || strncmp(cond, COND_DEV, strlen(COND_DEV)))
|
||||
return;
|
||||
|
||||
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"
|
||||
@@ -512,6 +513,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