Do proper cleanup, including websockets.

pull/211/merge
Roger A. Light 11 years ago
parent 764b7e0a91
commit cc33a6e5af

@ -130,7 +130,11 @@ int mosquitto_main_loop(struct mosquitto_db *db, int *listensock, int listensock
} }
context->pollfd_index = -1; context->pollfd_index = -1;
#ifdef WITH_WEBSOCKETS
if(context->sock != INVALID_SOCKET || context->wsi){
#else
if(context->sock != INVALID_SOCKET){ if(context->sock != INVALID_SOCKET){
#endif
#ifdef WITH_BRIDGE #ifdef WITH_BRIDGE
if(context->bridge){ if(context->bridge){
_mosquitto_check_keepalive(db, context); _mosquitto_check_keepalive(db, context);
@ -348,6 +352,9 @@ static void do_disconnect(struct mosquitto_db *db, struct mosquitto *context)
} }
} }
mqtt3_context_disconnect(db, context); mqtt3_context_disconnect(db, context);
if(context->clean_session){
mqtt3_context_cleanup(db, context, true);
}
} }
/* Error ocurred, probably an fd has been closed. /* Error ocurred, probably an fd has been closed.

@ -129,7 +129,11 @@ static int callback_mqtt(struct libwebsocket_context *context,
case LWS_CALLBACK_CLOSED: case LWS_CALLBACK_CLOSED:
mosq = u->mosq; mosq = u->mosq;
mqtt3_context_cleanup(db, mosq, true); mqtt3_context_disconnect(db, mosq);
if(context->clean_session){
mqtt3_context_cleanup(db, mosq, true);
}
mosq->wsi = NULL;
break; break;
case LWS_CALLBACK_SERVER_WRITEABLE: case LWS_CALLBACK_SERVER_WRITEABLE:

Loading…
Cancel
Save