diff --git a/lib/core-net/private.h b/lib/core-net/private.h index c4285a4cd..563c0214e 100644 --- a/lib/core-net/private.h +++ b/lib/core-net/private.h @@ -344,6 +344,9 @@ struct lws_context_per_thread { unsigned char inside_service:1; unsigned char event_loop_foreign:1; unsigned char event_loop_destroy_processing_done:1; +#ifdef _WIN32 + unsigned char interrupt_requested:1; +#endif }; struct lws_conn_stats { diff --git a/lib/plat/windows/windows-pipe.c b/lib/plat/windows/windows-pipe.c index af2af1fa8..ac6a0e8fd 100644 --- a/lib/plat/windows/windows-pipe.c +++ b/lib/plat/windows/windows-pipe.c @@ -35,6 +35,7 @@ lws_plat_pipe_signal(struct lws *wsi) { struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi]; + pt->interrupt_requested = 1; WSASetEvent(pt->events); /* trigger the cancel event */ return 0; diff --git a/lib/plat/windows/windows-service.c b/lib/plat/windows/windows-service.c index 4a9ff2c6a..9e52cf6f6 100644 --- a/lib/plat/windows/windows-service.c +++ b/lib/plat/windows/windows-service.c @@ -137,6 +137,12 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) ev = WSAWaitForMultipleEvents(1, &pt->events, FALSE, timeout_ms, FALSE); if (ev == WSA_WAIT_EVENT_0) { + if(pt->interrupt_requested) { + pt->interrupt_requested = 0; + lws_broadcast(context, LWS_CALLBACK_EVENT_WAIT_CANCELLED, NULL, 0); + return 0; + } + unsigned int eIdx; #if defined(LWS_WITH_TLS)