diff --git a/lib/output.c b/lib/output.c index b2359549..28e15a6d 100644 --- a/lib/output.c +++ b/lib/output.c @@ -153,9 +153,10 @@ handle_truncated_send: lwsl_info("***** %x partial send completed\n", wsi); /* done with it, but don't free it */ n = real_len; - if (wsi->state == WSI_STATE_FLUSHING_STORED_SEND_BEFORE_CLOSE) + if (wsi->state == WSI_STATE_FLUSHING_STORED_SEND_BEFORE_CLOSE) { lwsl_info("***** %x signalling to close now\n", wsi); return -1; /* retry closing now */ + } } /* always callback on writeable */ libwebsocket_callback_on_writable( diff --git a/lib/service.c b/lib/service.c index 85b6753d..9aa743e5 100644 --- a/lib/service.c +++ b/lib/service.c @@ -42,7 +42,12 @@ lws_handle_POLLOUT_event(struct libwebsocket_context *context, } /* leave POLLOUT active either way */ return 0; - } + } else + if (wsi->state == WSI_STATE_FLUSHING_STORED_SEND_BEFORE_CLOSE) { + lwsl_info("***** %x signalling to close in POLLOUT handler\n", wsi); + return -1; /* retry closing now */ + } + m = lws_ext_callback_for_each_active(wsi, LWS_EXT_CALLBACK_IS_WRITEABLE, NULL, 0);