From fa31b6f41d69394dce9424a04e4f95d5fb2cfdc2 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Sat, 13 Aug 2022 22:46:19 +0100 Subject: [PATCH] Fix bridge queued messages not being persisted. This happens when local_cleansession is set to false and cleansession is set to true. Closes #2604. Thank to Frank Dekervel. --- ChangeLog.txt | 2 ++ src/persist_write.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index a0614d894..5a165de1a 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -22,6 +22,8 @@ Broker: security plugin. Closes #2525. - Fix confusing error message when dynamic security config file was a directory. Closes #2520. +- Fix bridge queued messages not being persisted when local_cleansession is + set to false and cleansession is set to true. Closes #2604. Client library: - Fix threads library detection on Windows under cmake. Bumps the minimum diff --git a/src/persist_write.c b/src/persist_write.c index 0df016ec0..fb3632fee 100644 --- a/src/persist_write.c +++ b/src/persist_write.c @@ -167,7 +167,11 @@ static int persist__client_save(FILE *db_fptr) memset(&chunk, 0, sizeof(struct P_client)); HASH_ITER(hh_id, db.contexts_by_id, context, ctxt_tmp){ - if(context && context->clean_start == false){ + if(context && (context->clean_start == false +#ifdef WITH_BRIDGE + || (context->bridge && context->bridge->clean_start_local == false) +#endif + )){ chunk.F.session_expiry_time = context->session_expiry_time; if(context->session_expiry_interval != 0 && context->session_expiry_interval != UINT32_MAX && context->session_expiry_time == 0){ chunk.F.session_expiry_time = context->session_expiry_interval + db.now_real_s;