From e755827f4f1da3eb83c20b174396cb68d642f257 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 5 May 2020 15:35:49 +0100 Subject: [PATCH] Free outgoing client messages even for non-bridges. --- src/context.c | 6 +++++- src/database.c | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/context.c b/src/context.c index a8104e28..957a744e 100644 --- a/src/context.c +++ b/src/context.c @@ -103,6 +103,10 @@ void context__cleanup(struct mosquitto_db *db, struct mosquitto *context, bool d if(!context) return; + if(do_free){ + context->clean_start = true; + } + #ifdef WITH_BRIDGE if(context->bridge){ bridge__cleanup(db, context); @@ -121,7 +125,7 @@ void context__cleanup(struct mosquitto_db *db, struct mosquitto *context, bool d context->password = NULL; net__socket_close(db, context); - if(do_free || context->clean_start){ + if(do_free){ sub__clean_session(db, context); } db__messages_delete(db, context); diff --git a/src/database.c b/src/database.c index 20a4ad9a..ddbf948a 100644 --- a/src/database.c +++ b/src/database.c @@ -124,7 +124,7 @@ int db__open(struct mosquitto__config *config, struct mosquitto_db *db) db->bridge_count = 0; #endif - // Initialize the hashtable + /* Initialize the hashtable */ db->clientid_index_hash = NULL; db->subs = NULL; @@ -573,7 +573,9 @@ int db__messages_delete(struct mosquitto_db *db, struct mosquitto *context) context->msgs_in.msg_count12 = 0; } - if(context->bridge && context->bridge->clean_start_local){ + if((context->bridge && context->bridge->clean_start_local) + || (context->bridge == NULL && context->clean_start)){ + db__messages_delete_list(db, &context->msgs_out.inflight); db__messages_delete_list(db, &context->msgs_out.queued); context->msgs_out.msg_bytes = 0;