peer closes during partial buffered just hang up
authorAndy Green <andy@warmcat.com>
Sat, 2 Jul 2016 01:23:15 +0000 (09:23 +0800)
committerAndy Green <andy@warmcat.com>
Thu, 14 Jul 2016 00:57:27 +0000 (08:57 +0800)
https://github.com/warmcat/libwebsockets/issues/573

lib/parsers.c

index bdc5bc2..ee75ecc 100644 (file)
@@ -1268,6 +1268,17 @@ spill:
                                /* if he sends us 2 CLOSE, kill him */
                                return -1;
 
+                       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;
+                               lwsl_parser("Closing on peer close due to Pending tx\n");
+                               return -1;
+                       }
+
                        if (user_callback_handle_rxflow(
                                        wsi->protocol->callback, wsi,
                                        LWS_CALLBACK_WS_PEER_INITIATED_CLOSE,