diff --git a/lib/service.c b/lib/service.c index 11c33b0c6..1b5dcf423 100644 --- a/lib/service.c +++ b/lib/service.c @@ -512,6 +512,8 @@ libwebsocket_service_fd(struct libwebsocket_context *context, wsi->state == WSI_STATE_RETURNED_CLOSE_ALREADY || wsi->state == WSI_STATE_FLUSHING_STORED_SEND_BEFORE_CLOSE) && lws_handle_POLLOUT_event(context, wsi, pollfd)) { + if (wsi->state == WSI_STATE_RETURNED_CLOSE_ALREADY) + wsi->state = WSI_STATE_FLUSHING_STORED_SEND_BEFORE_CLOSE; lwsl_info("libwebsocket_service_fd: closing\n"); goto close_and_handled; }