From: Andy Green Date: Mon, 27 Feb 2017 20:03:26 +0000 (+0800) Subject: client: take care of rx close during pending partial same as server does X-Git-Tag: accepted/tizen/4.0/unified/20171012.191640~206 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=73dda1f765b446989aeb9e71f9fe5f0fb3f72b88;p=platform%2Fupstream%2Flibwebsockets.git client: take care of rx close during pending partial same as server does https://github.com/warmcat/libwebsockets/issues/816 --- diff --git a/lib/client-parser.c b/lib/client-parser.c index 2151342..ba1921b 100644 --- a/lib/client-parser.c +++ b/lib/client-parser.c @@ -381,13 +381,22 @@ spill: wsi->user_space, pp, wsi->u.ws.rx_ubuf_head)) return -1; - /* - * parrot the close packet payload back - * we do not care about how it went, we are closing - * immediately afterwards - */ - lws_write(wsi, (unsigned char *)&wsi->u.ws.rx_ubuf[LWS_PRE], - wsi->u.ws.rx_ubuf_head, LWS_WRITE_CLOSE); + if (lws_partial_buffered(wsi)) + /* + * if we're in the middle of something, + * we can't do a normal close response and + * have to just close our end. + */ + wsi->socket_is_permanently_unusable = 1; + else + /* + * parrot the close packet payload back + * we do not care about how it went, we are closing + * immediately afterwards + */ + lws_write(wsi, (unsigned char *)&wsi->u.ws.rx_ubuf[LWS_PRE], + wsi->u.ws.rx_ubuf_head, + LWS_WRITE_CLOSE); wsi->state = LWSS_RETURNED_CLOSE_ALREADY; /* close the connection */ return -1;