diff options
author | José Bollo <jose.bollo@iot.bzh> | 2018-02-22 13:22:48 +0100 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2018-02-22 13:22:48 +0100 |
commit | ca820c65c2b03a24e8936218171c6c1d138fd1f7 (patch) | |
tree | f7e31ea8e63d3321af64226e360a78c504a09bb3 /src/afb-ws-json1.c | |
parent | f15ea770dd9b13a20331853a026091316984f9ca (diff) |
fdev: Introduce fdev for file event handling
This is an effort to keep cutting dependency to systemd.
Change-Id: I9a0c032a1095e297c7f3ac5b67827fda3658b8d9
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-ws-json1.c')
-rw-r--r-- | src/afb-ws-json1.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/afb-ws-json1.c b/src/afb-ws-json1.c index 0fa13dfd..68565aa2 100644 --- a/src/afb-ws-json1.c +++ b/src/afb-ws-json1.c @@ -36,6 +36,7 @@ #include "afb-context.h" #include "afb-evt.h" #include "verbose.h" +#include "fdev.h" /* predeclaration of structures */ struct afb_ws_json1; @@ -99,11 +100,11 @@ static const struct afb_evt_itf evt_itf = { **************************************************************** ***************************************************************/ -struct afb_ws_json1 *afb_ws_json1_create(int fd, struct afb_apiset *apiset, struct afb_context *context, void (*cleanup)(void*), void *cleanup_closure) +struct afb_ws_json1 *afb_ws_json1_create(struct fdev *fdev, struct afb_apiset *apiset, struct afb_context *context, void (*cleanup)(void*), void *cleanup_closure) { struct afb_ws_json1 *result; - assert(fd >= 0); + assert(fdev); assert(context != NULL); result = malloc(sizeof * result); @@ -118,7 +119,7 @@ struct afb_ws_json1 *afb_ws_json1_create(int fd, struct afb_apiset *apiset, stru if (result->session == NULL) goto error2; - result->wsj1 = afb_wsj1_create(afb_systemd_get_event_loop(), fd, &wsj1_itf, result); + result->wsj1 = afb_wsj1_create(fdev, &wsj1_itf, result); if (result->wsj1 == NULL) goto error3; @@ -126,7 +127,7 @@ struct afb_ws_json1 *afb_ws_json1_create(int fd, struct afb_apiset *apiset, stru if (result->listener == NULL) goto error4; - result->cred = afb_cred_create_for_socket(fd); + result->cred = afb_cred_create_for_socket(fdev_fd(fdev)); result->apiset = afb_apiset_addref(apiset); return result; @@ -137,7 +138,7 @@ error3: error2: free(result); error: - close(fd); + fdev_unref(fdev); return NULL; } |