From 365eb7f29556f52fd3902130d5c967119a9a6b3a Mon Sep 17 00:00:00 2001
From: Andy Green <andy@warmcat.com>
Date: Wed, 24 Jan 2018 08:25:26 +0800
Subject: [PATCH] close: add LWSS_WAITING_TO_SEND_CLOSE_NOTIFICATION allowed to
 send

https://github.com/warmcat/libwebsockets/issues/1159
---
 lib/output.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/output.c b/lib/output.c
index 465cb5f7..c0ad1f8d 100644
--- a/lib/output.c
+++ b/lib/output.c
@@ -315,9 +315,12 @@ LWS_VISIBLE int lws_write(struct lws *wsi, unsigned char *buf, size_t len,
 
 	if (wsi->state != LWSS_ESTABLISHED &&
 	    ((wsi->state != LWSS_RETURNED_CLOSE_ALREADY &&
+	      wsi->state != LWSS_WAITING_TO_SEND_CLOSE_NOTIFICATION &&
 	      wsi->state != LWSS_AWAITING_CLOSE_ACK) ||
-			    wp != LWS_WRITE_CLOSE))
+			    wp != LWS_WRITE_CLOSE)) {
+		lwsl_debug("binning\n");
 		return 0;
+	}
 
 	/* if we are continuing a frame that already had its header done */
 
-- 
GitLab