fdev: Introduce fdev for file event handling
[src/app-framework-binder.git] / src / afs-supervisor.c
index 35a3f3e..1e92b9f 100644 (file)
@@ -36,7 +36,7 @@
 #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"
@@ -45,6 +45,7 @@
 #include "afb-api-so-v2.h"
 #include "afb-api-ws.h"
 #include "afb-apiset.h"
+#include "afb-fdev.h"
 #include "jobs.h"
 #include "verbose.h"
 #include "wrap-json.h"
@@ -193,13 +194,20 @@ static void on_supervised_hangup(struct afb_stub_ws *stub)
 static int make_supervised(int fd, struct afb_cred *cred)
 {
        struct supervised *s;
+       struct fdev *fdev;
 
        s = malloc(sizeof *s);
        if (!s)
                return -1;
 
+       fdev = afb_fdev_create(fd);
+       if (!fdev) {
+               free(s);
+               return -1;
+       }
+
        s->cred = cred;
-       s->stub = afb_stub_ws_create_client(fd, supervision_apiname, empty_apiset);
+       s->stub = afb_stub_ws_create_client(fdev, supervision_apiname, empty_apiset);
        if (!s->stub) {
                free(s);
                return -1;
@@ -339,7 +347,7 @@ static int init(const char *spec)
        }
 
        /* 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) {