aboutsummaryrefslogtreecommitdiffstats
path: root/src/afs-supervisor.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2018-02-14 15:18:34 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2018-02-14 15:18:34 +0100
commita6e6791f45941063b17a100a6d5d5c9e5cf250d3 (patch)
treeb52b41695a878e941419dd1c31d99e47c3360eff /src/afs-supervisor.c
parentabbb4599f0b921c6f434b6bd02bcfb277eecf745 (diff)
afs-supervisor: Add verb for running discovery
Change-Id: Iea9e54fa7a1c93ba3927c836d6ca5bcded77ca66 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afs-supervisor.c')
-rw-r--r--src/afs-supervisor.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/afs-supervisor.c b/src/afs-supervisor.c
index 8cf21cb5..35a3f3e1 100644
--- a/src/afs-supervisor.c
+++ b/src/afs-supervisor.c
@@ -277,13 +277,17 @@ static void discovered_cb(void *closure, pid_t pid)
struct supervised *s;
s = supervised_of_pid(pid);
- if (!s)
+ if (!s) {
+ (*(int*)closure)++;
kill(pid, SIGHUP);
+ }
}
-static void discover_supervised()
+static int discover_supervised()
{
- afs_discover("afb-daemon", discovered_cb, NULL);
+ int n = 0;
+ afs_discover("afb-daemon", discovered_cb, &n);
+ return n;
}
/**
@@ -411,6 +415,12 @@ static void f_list(struct afb_req req)
afb_req_success(req, resu, NULL);
}
+static void f_discover(struct afb_req req)
+{
+ discover_supervised();
+ afb_req_success(req, NULL, NULL);
+}
+
static void propagate(struct afb_req req, const char *verb)
{
struct afb_xreq *xreq;
@@ -555,6 +565,13 @@ static const struct afb_verb_v2 _afb_verbs_v2_supervision[] = {
.info = NULL,
.session = AFB_SESSION_NONE_V2
},
+ {
+ .verb = "discover",
+ .callback = f_discover,
+ .auth = &_afb_auths_v2_supervision[0],
+ .info = NULL,
+ .session = AFB_SESSION_NONE_V2
+ },
{ .verb = NULL }
};