#include <afb/afb-binding-v2.h>
#include "afs-supervision.h"
-#include "afb-common.h"
+#include "afb-systemd.h"
#include "afb-session.h"
#include "afb-cred.h"
#include "afb-stub-ws.h"
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;
}
/**
}
/* integrate the socket to the loop */
- rc = sd_event_add_io(afb_common_get_event_loop(),
+ rc = sd_event_add_io(afb_systemd_get_event_loop(),
NULL, fd, EPOLLIN,
listening, NULL);
if (rc < 0) {
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;
.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 }
};