From f7aff789ca5e57e3cba52d9ee03cf78b1e193fe7 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Wed, 8 Dec 2021 06:28:16 +0000 Subject: [PATCH] cancel pipe: mark close when wsi is close --- lib/core-net/close.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/core-net/close.c b/lib/core-net/close.c index 7eeb3eaada..4388aaf4c9 100644 --- a/lib/core-net/close.c +++ b/lib/core-net/close.c @@ -903,6 +903,18 @@ __lws_close_free_wsi_final(struct lws *wsi) sanity_assert_no_sockfd_traces(wsi->a.context, wsi->desc.sockfd); } + /* ... if we're closing the cancel pipe, account for it */ + + { + struct lws_context_per_thread *pt = + &wsi->a.context->pt[(int)wsi->tsi]; + + if (pt->pipe_wsi == wsi) + pt->pipe_wsi = NULL; + if (pt->dummy_pipe_fds[0] == wsi->desc.sockfd) + pt->dummy_pipe_fds[0] = LWS_SOCK_INVALID; + } + wsi->desc.sockfd = LWS_SOCK_INVALID; #if defined(LWS_WITH_CLIENT)