diff options
author | José Bollo <jose.bollo@iot.bzh> | 2016-07-27 15:51:01 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2016-07-27 17:40:58 +0200 |
commit | 1ea6bd0f466a10d29f12801aa35fb6d2b30443a1 (patch) | |
tree | 308bbc689182de8cfd9e42f76dea57455d3a5434 /src/afb-ws.c | |
parent | 1d0f869ce3379089b4f4c5285e3d30e971e5b93d (diff) |
Expose use of the event loop
The use of the event loop where previously hidden
in internal deep places of the websocket modules.
This commits enforce the client of the library to
explicitely tell what event loop must be used.
This has 3 effects:
- you know that the systemd event loop is used
- you tell the event loop to use (no confusion)
- you don't depend on afb-common.c
Change-Id: Id13d8a96f981183c299cde414d9bb0cd77fe3daa
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-ws.c')
-rw-r--r-- | src/afb-ws.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/afb-ws.c b/src/afb-ws.c index 34796818..53fb60ae 100644 --- a/src/afb-ws.c +++ b/src/afb-ws.c @@ -135,10 +135,12 @@ static int io_event_callback(sd_event_source *src, int fd, uint32_t revents, voi * Creates the afb_ws structure for the file descritor * 'fd' and the callbacks described by the interface 'itf' * and its 'closure'. + * When the creation is a success, the systemd event loop 'eloop' is + * used for handling event for 'fd'. * * Returns the handle for the afb_ws created or NULL on error. */ -struct afb_ws *afb_ws_create(int fd, const struct afb_ws_itf *itf, void *closure) +struct afb_ws *afb_ws_create(struct sd_event *eloop, int fd, const struct afb_ws_itf *itf, void *closure) { int rc; struct afb_ws *result; @@ -164,7 +166,7 @@ struct afb_ws *afb_ws_create(int fd, const struct afb_ws_itf *itf, void *closure goto error2; /* creates the evsrc */ - rc = sd_event_add_io(afb_common_get_event_loop(), &result->evsrc, result->fd, EPOLLIN, io_event_callback, result); + rc = sd_event_add_io(eloop, &result->evsrc, result->fd, EPOLLIN, io_event_callback, result); if (rc < 0) { errno = -rc; goto error3; |