diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index e9fcb5af..b8a49947 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -402,6 +402,8 @@ lws_close_free_wsi(struct lws *wsi, enum lws_close_status reason) goto async_close; } + wsi->state_pre_close = wsi->state; + #ifdef LWS_WITH_CGI if (wsi->mode == LWSCM_CGI) { /* we are not a network connection, but a handler for CGI io */ @@ -446,8 +448,6 @@ lws_close_free_wsi(struct lws *wsi, enum lws_close_status reason) wsi->state == LWSS_SHUTDOWN) goto just_kill_connection; - wsi->state_pre_close = wsi->state; - switch (wsi->state_pre_close) { case LWSS_DEAD_SOCKET: return;