From b52e3311d258dc105cb5c7ab692aa587fcd86ecc Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 7 Jan 2015 23:33:31 +0000 Subject: [PATCH] Disconnect websockets clients properly. context->state was being overwritten when websockets clients attempted to disconnect, leaving them in limbo. This has been fixed. Thanks to FeelyChau. --- src/loop.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/loop.c b/src/loop.c index 088c33fc..32c7950d 100644 --- a/src/loop.c +++ b/src/loop.c @@ -353,8 +353,9 @@ void do_disconnect(struct mosquitto_db *db, struct mosquitto *context) libwebsocket_callback_on_writable(context->ws_context, context->wsi); } context->sock = INVALID_SOCKET; - }else{ + }else #endif + { if(db->config->connection_messages == true){ if(context->state != mosq_cs_disconnecting){ _mosquitto_log_printf(NULL, MOSQ_LOG_NOTICE, "Socket error on client %s, disconnecting.", context->id); @@ -375,10 +376,8 @@ void do_disconnect(struct mosquitto_db *db, struct mosquitto *context) context->id = NULL; } } -#ifdef WITH_WEBSOCKETS + context->state = mosq_cs_disconnected; } -#endif - context->state = mosq_cs_disconnected; } /* Error ocurred, probably an fd has been closed.