X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=src%2Fapp-framework-binder.git;a=blobdiff_plain;f=src%2Fafb-api-ws.c;h=4ea8610e801b19406984e39ada70603e390a6dbf;hp=3d2445ac00b2abbb3d72a38dcf6a4ca10a27c612;hb=65353dce81a629e042800bb7b86fcd869a76727e;hpb=60cd11786766ebc148b7ec088962dd6e112f8762 diff --git a/src/afb-api-ws.c b/src/afb-api-ws.c index 3d2445ac..4ea8610e 100644 --- a/src/afb-api-ws.c +++ b/src/afb-api-ws.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2019 "IoT.bzh" + * Copyright (C) 2015-2020 "IoT.bzh" * Author José Bollo * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -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); } } @@ -142,10 +144,10 @@ static void api_ws_server_listen_callback(void *closure, uint32_t revents, struc { struct api_ws_server *apiws = closure; - if ((revents & EPOLLIN) != 0) - api_ws_server_accept(apiws); if ((revents & EPOLLHUP) != 0) api_ws_server_connect(apiws); + else if ((revents & EPOLLIN) != 0) + api_ws_server_accept(apiws); } static void api_ws_server_disconnect(struct api_ws_server *apiws)