diff --git a/lib/event-libs/libuv/libuv.c b/lib/event-libs/libuv/libuv.c index c38eb2ac5..7ea7eb846 100644 --- a/lib/event-libs/libuv/libuv.c +++ b/lib/event-libs/libuv/libuv.c @@ -614,6 +614,7 @@ elops_close_handle_manually_uv(struct lws *wsi) wsi->desc.sockfd = LWS_SOCK_INVALID; wsi->w_read.uv.pwatcher = NULL; + wsi->told_event_loop_closed = 1; uv_close(h, lws_libuv_closewsi_m); } @@ -665,6 +666,12 @@ elops_io_uv(struct lws *wsi, int flags) assert(0); } + if (!w->uv.pwatcher || wsi->told_event_loop_closed) { + lwsl_err("%s: no watcher\n", __func__); + + return; + } + if (flags & LWS_EV_START) { if (flags & LWS_EV_WRITE) current_events |= UV_WRITABLE;