aboutsummaryrefslogtreecommitdiffstats
path: root/src/afb-api-ws.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2019-07-10 00:06:36 +0200
committerJose Bollo <jose.bollo@iot.bzh>2019-07-18 15:42:27 +0200
commitad66a4685f5d50ef05338157c84a572088693ed3 (patch)
treedad3d2aa8d11920735f49d368c9f9f7f3a5972d8 /src/afb-api-ws.c
parent037157919df0a7ee90837037748a6456431e6469 (diff)
Fix bad memory access at client disconnection
The management of structures handling a client connection to a exported --ws-server was accessing freed memory. Tha commit fixes that issue. Bug-AGL: SPEC-2651 Change-Id: I511218afc907308347bc422a8aead32ca00bdae6 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-api-ws.c')
-rw-r--r--src/afb-api-ws.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/afb-api-ws.c b/src/afb-api-ws.c
index 65daf025..dc45edbb 100644
--- a/src/afb-api-ws.c
+++ b/src/afb-api-ws.c
@@ -130,7 +130,9 @@ static void api_ws_server_accept(struct api_ws_server *apiws)
close(fd);
} else {
server = afb_stub_ws_create_server(fdev, &apiws->uri[apiws->offapi], apiws->apiset);
- if (!server)
+ if (server)
+ afb_stub_ws_set_on_hangup(server, afb_stub_ws_unref);
+ else
ERROR("can't serve accepted connection to %s: %m", apiws->uri);
}
}
@@ -144,7 +146,7 @@ static void api_ws_server_listen_callback(void *closure, uint32_t revents, struc
if ((revents & EPOLLIN) != 0)
api_ws_server_accept(apiws);
- if ((revents & EPOLLHUP) != 0)
+ else if ((revents & EPOLLHUP) != 0)
api_ws_server_connect(apiws);
}