Free outgoing client messages even for non-bridges.

This commit is contained in:
Roger A. Light 2020-05-05 15:35:49 +01:00
parent ee7d1981ff
commit e755827f4f
2 changed files with 9 additions and 3 deletions

View File

@ -103,6 +103,10 @@ void context__cleanup(struct mosquitto_db *db, struct mosquitto *context, bool d
if(!context) return; if(!context) return;
if(do_free){
context->clean_start = true;
}
#ifdef WITH_BRIDGE #ifdef WITH_BRIDGE
if(context->bridge){ if(context->bridge){
bridge__cleanup(db, context); bridge__cleanup(db, context);
@ -121,7 +125,7 @@ void context__cleanup(struct mosquitto_db *db, struct mosquitto *context, bool d
context->password = NULL; context->password = NULL;
net__socket_close(db, context); net__socket_close(db, context);
if(do_free || context->clean_start){ if(do_free){
sub__clean_session(db, context); sub__clean_session(db, context);
} }
db__messages_delete(db, context); db__messages_delete(db, context);

View File

@ -124,7 +124,7 @@ int db__open(struct mosquitto__config *config, struct mosquitto_db *db)
db->bridge_count = 0; db->bridge_count = 0;
#endif #endif
// Initialize the hashtable /* Initialize the hashtable */
db->clientid_index_hash = NULL; db->clientid_index_hash = NULL;
db->subs = 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; 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.inflight);
db__messages_delete_list(db, &context->msgs_out.queued); db__messages_delete_list(db, &context->msgs_out.queued);
context->msgs_out.msg_bytes = 0; context->msgs_out.msg_bytes = 0;