From ca8f00fab51179e8e501a7121f4dc68afabe607a Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Thu, 1 May 2025 13:44:48 +0100 Subject: [PATCH] Fix compilation using WITH_OLD_KEEPALIVE Closes #3250. Thanks to Stefan Bigler --- ChangeLog.txt | 1 + src/CMakeLists.txt | 6 ++++++ src/keepalive.c | 8 -------- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 5f915e90..5a9a58c4 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -14,6 +14,7 @@ Broker: Closes #3238. - Fix reporting of client disconnections being incorrectly attributed to "out of memory". Closes #3253. +- Fix compilation when using `WITH_OLD_KEEPALIVE`. Closes #3250. Client library: - Fix C++ symbols being removed when compiled with link time optimisation. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0b328e0e..d4bae7cd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -113,6 +113,12 @@ if (WITH_PERSISTENCE) add_definitions("-DWITH_PERSISTENCE") endif (WITH_PERSISTENCE) +option(WITH_OLD_KEEPALIVE + "Use legacy keepalive check mechanism?" OFF) +if (WITH_OLD_KEEPALIVE) + add_definitions("-DWITH_OLD_KEEPALIVE") +endif (WITH_OLD_KEEPALIVE) + option(WITH_SYS_TREE "Include $SYS tree support?" ON) if (WITH_SYS_TREE) diff --git a/src/keepalive.c b/src/keepalive.c index 03eace93..b29b25a3 100644 --- a/src/keepalive.c +++ b/src/keepalive.c @@ -146,15 +146,7 @@ void keepalive__check(void) void keepalive__check(void) { struct mosquitto *context, *ctxt_tmp; - time_t timeout; - if(db.contexts_by_sock){ - timeout = (last_keepalive_check + 5 - db.now_s); - if(timeout <= 0){ - timeout = 5; - } - loop__update_next_event(timeout*1000); - } if(last_keepalive_check + 5 <= db.now_s){ last_keepalive_check = db.now_s;