[Libwebsockets] BUG: libwebsocket_context_destroy fails to close websocket properly

Tony yellowjacketlite at gmail.com
Thu Dec 4 21:40:03 CET 2014


While investigating my question regarding my issue with proper client side
shutdown, I think I uncovered a bug.

In libwebsocket_context_destroy, libwebsocket_close_and_free_session is
called with a shutdown reason of LWS_CLOSE_STATUS_NOSTATUS.  However the
code of libwebsocket_close_and_free_session, it expects the 'reason' to be
anything but LWS_CLOSE_STATUS_NOSTATUS.

Here's the line...

    if (old_state == WSI_STATE_ESTABLISHED &&
                      reason != LWS_CLOSE_STATUS_NOSTATUS) {
   // perform shutdown step 1
    }

I'm not sure of the correct fix, but I __think__ either
libwebsocket_context_destroy should pass in, say, LWS_CLOSE_STATUS_NORMAL,
or the above if statement should be changed to read...

    if (old_state == WSI_STATE_ESTABLISHED &&
                      reason == LWS_CLOSE_STATUS_NOSTATUS) {
   // perform shutdown step 1
    }

-- 
Tony
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://libwebsockets.org/pipermail/libwebsockets/attachments/20141204/a2460aee/attachment.html>


More information about the Libwebsockets mailing list