From 7f18ced0b4a85c22586e09798d901480a2e7f39f Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Thu, 26 Jun 2014 22:13:22 +0100 Subject: [PATCH] Close websockets connection if we are set to disconnecting. --- src/websockets.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/websockets.c b/src/websockets.c index 8594e18f..29bdd89f 100644 --- a/src/websockets.c +++ b/src/websockets.c @@ -138,6 +138,10 @@ static int callback_mqtt(struct libwebsocket_context *context, case LWS_CALLBACK_SERVER_WRITEABLE: mosq = u->mosq; + if(mosq->state == mosq_cs_disconnecting){ + return -1; + } + if(mosq->out_packet && !mosq->current_out_packet){ mosq->current_out_packet = mosq->out_packet; mosq->out_packet = mosq->out_packet->next;