From 82eccf7611803461df6614c6d109187ee3e5604f Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sun, 26 Apr 2015 05:32:03 +0800 Subject: [PATCH] close send close ack control packet type Noticed by Andrey Pokrovskiy Close processing reused ping processing to save and send the payload, and sets a flag to know it's close, but forgot to change the control packet accordingly. Signed-off-by: Andy Green --- lib/service.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/service.c b/lib/service.c index 40cef568..4ae47c72 100644 --- a/lib/service.c +++ b/lib/service.c @@ -55,6 +55,7 @@ lws_handle_POLLOUT_event(struct libwebsocket_context *context, #endif int ret; int m; + int write_type = LWS_WRITE_PONG; /* pending truncated sends have uber priority */ @@ -94,11 +95,15 @@ lws_handle_POLLOUT_event(struct libwebsocket_context *context, if (wsi->state == WSI_STATE_ESTABLISHED && wsi->u.ws.ping_pending_flag) { + + if (wsi->u.ws.payload_is_close) + write_type = LWS_WRITE_CLOSE; + n = libwebsocket_write(wsi, &wsi->u.ws.ping_payload_buf[ LWS_SEND_BUFFER_PRE_PADDING], wsi->u.ws.ping_payload_len, - LWS_WRITE_PONG); + write_type); if (n < 0) return -1;