From 6d240a9d183413fca7d2a4f42eae803ba84af97c Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Sat, 8 Apr 2023 09:07:56 +0100 Subject: [PATCH] Fix bridges being expired after being restored. This occurred with non-matching cleansession/local_cleansession being expired on start after restoring from persistence. Closes #2634. Thanks to everyone on the issue. --- ChangeLog.txt | 2 ++ src/persist_write.c | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 75a03b18..351eaad1 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,8 @@ Broker: assertions removed. Closes #2708. - Fix default settings incorrectly allowing TLS v1.1. Closes #2722. - Use line buffered mode for stdout. Closes #2354. Closes #2749. +- Fix bridges with non-matching cleansession/local_cleansession being expired + on start after restoring from persistence. Closes #2634. - Fix connections being limited to 2048 on Windows. The limit is now 8192, where supported. Closes #2732. diff --git a/src/persist_write.c b/src/persist_write.c index fb3632fe..f0949f8a 100644 --- a/src/persist_write.c +++ b/src/persist_write.c @@ -167,11 +167,14 @@ 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 && #ifdef WITH_BRIDGE - || (context->bridge && context->bridge->clean_start_local == false) + ((!context->bridge && context->clean_start == false) + || (context->bridge && context->bridge->clean_start_local == false)) +#else + context->clean_start == 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;