1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

Subject: [PATCH] Fix for close ack sending

It was forgotten in two places that pending close ack should be
processed when wsi state is WSI_STATE_RETURNED_CLOSE_ALREADY, but
not WSI_STATE_ESTABLISHED. As a result, close ack wasn't sent out
to the peer.
This commit is contained in:
Andrejs Hanins 2015-11-06 18:18:32 +02:00 committed by Andy Green
parent 79a3c5d425
commit 140ac6e9cb
2 changed files with 7 additions and 3 deletions

View file

@ -270,7 +270,9 @@ LWS_VISIBLE int libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf,
/* websocket protocol, either binary or text */
if (wsi->state != WSI_STATE_ESTABLISHED)
if (wsi->state != WSI_STATE_ESTABLISHED &&
!(wsi->state == WSI_STATE_RETURNED_CLOSE_ALREADY &&
protocol == LWS_WRITE_CLOSE))
return -1;
/* if we are continuing a frame that already had its header done */

View file

@ -93,8 +93,10 @@ lws_handle_POLLOUT_event(struct libwebsocket_context *context,
#endif
/* pending control packets have next priority */
if (wsi->state == WSI_STATE_ESTABLISHED &&
wsi->u.ws.ping_pending_flag) {
if ((wsi->state == WSI_STATE_ESTABLISHED &&
wsi->u.ws.ping_pending_flag) ||
(wsi->state == WSI_STATE_RETURNED_CLOSE_ALREADY &&
wsi->u.ws.payload_is_close)) {
if (wsi->u.ws.payload_is_close)
write_type = LWS_WRITE_CLOSE;