defeat POLLOUT if socket in shutdown wait
authorAndy Green <andy.green@linaro.org>
Wed, 24 Feb 2016 13:32:31 +0000 (21:32 +0800)
committerAndy Green <andy.green@linaro.org>
Wed, 24 Feb 2016 13:32:31 +0000 (21:32 +0800)
After andrejs.hanins@ubnt.com

Signed-off-by: Andy Green <andy.green@linaro.org>
changelog
lib/libwebsockets.c
lib/pollfd.c

index b7a31ef..8f47c6c 100644 (file)
--- a/changelog
+++ b/changelog
@@ -6,6 +6,14 @@ Fixes
 
 1) libuv one-per-session valgrind leak fixed
 
+2) MINOR An error about hdr struct in _lws_ws_related is corrected, it's not
+known to affect anything added until after it was fixed
+
+3) MINOR During the close shutdown wait state introduced at v1.7, if something
+requests callback on writeable for the socket it will busywait until the
+socket closes
+
+
 Changes
 -------
 
index 26d8868..b4bac9f 100644 (file)
@@ -299,8 +299,9 @@ just_kill_connection:
                n = shutdown(wsi->sock, SHUT_WR);
                if (n)
                        lwsl_debug("closing: shutdown ret %d\n", LWS_ERRNO);
-               wsi->state = LWSS_SHUTDOWN;
+
                lws_change_pollfd(wsi, LWS_POLLOUT, LWS_POLLIN);
+               wsi->state = LWSS_SHUTDOWN;
                lws_set_timeout(wsi, PENDING_TIMEOUT_SHUTDOWN_FLUSH,
                                context->timeout_secs);
                return;
index fb86fbd..65a28e4 100644 (file)
@@ -277,7 +277,12 @@ lws_callback_on_writable(struct lws *wsi)
 #ifdef LWS_USE_HTTP2
        struct lws *network_wsi, *wsi2;
        int already;
+#endif
+
+       if (wsi->state == LWSS_SHUTDOWN)
+               return 0;
 
+#ifdef LWS_USE_HTTP2
        lwsl_info("%s: %p\n", __func__, wsi);
 
        if (wsi->mode != LWSCM_HTTP2_SERVING)