diff --git a/lib/core-net/close.c b/lib/core-net/close.c index 6e66d5592..06e1266b3 100644 --- a/lib/core-net/close.c +++ b/lib/core-net/close.c @@ -505,6 +505,10 @@ just_kill_connection: lwsl_debug("%s: real just_kill_connection A: %s (sockfd %d)\n", __func__, lws_wsi_tag(wsi), wsi->desc.sockfd); +#if defined(LWS_WITH_THREADPOOL) + lws_threadpool_wsi_closing(wsi); +#endif + #if defined(LWS_WITH_FILE_OPS) && (defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2)) if (lwsi_role_http(wsi) && lwsi_role_server(wsi) && wsi->http.fop_fd != NULL) diff --git a/lib/core-net/private-lib-core-net.h b/lib/core-net/private-lib-core-net.h index 715976c4b..7bfb7ee65 100644 --- a/lib/core-net/private-lib-core-net.h +++ b/lib/core-net/private-lib-core-net.h @@ -1417,6 +1417,9 @@ html_parser_cb(const hubbub_token *token, void *pw); int lws_threadpool_tsi_context(struct lws_context *context, int tsi); +void +lws_threadpool_wsi_closing(struct lws *wsi); + void __lws_wsi_remove_from_sul(struct lws *wsi); diff --git a/lib/misc/threadpool/threadpool.c b/lib/misc/threadpool/threadpool.c index dd310b82e..27dae3058 100644 --- a/lib/misc/threadpool/threadpool.c +++ b/lib/misc/threadpool/threadpool.c @@ -1162,6 +1162,22 @@ lws_threadpool_foreach_task_ss(struct lws_ss_handle *ss, void *user, } #endif +static int +disassociate_wsi(struct lws_threadpool_task *task, + void *user) +{ + task->args.wsi = NULL; + lws_dll2_remove(&task->list); + + return 0; +} + +void +lws_threadpool_wsi_closing(struct lws *wsi) +{ + lws_threadpool_foreach_task_wsi(wsi, NULL, disassociate_wsi); +} + struct lws_threadpool_task * lws_threadpool_get_task_wsi(struct lws *wsi) {