Skip to content

Cannot compile mosquitto 2.0.21 with option WITH_OLD_KEEPALIVE set #3250

Description

@bigstefan

We were suffering from #3138 after update from 2.0.18 to 2.0.20.
If the system time is changed all clients are disconnected from the broker

Now I tried to update to 2.0.21 and tried to set WITH_OLD_KEEPALIVE to overcome the disconnect problem.
But we cannot compile due to missing symbols

src/keepalive.c:157:17: warning: implicit declaration of function 'loop__update_next_event' [-Wimplicit-function-declaration]
|   157 |                 loop__update_next_event(timeout*1000);
|       |                 ^~~~~~~~~~~~~~~~~~~~~~~

we compile for linux with cmake so I added in CMakeLists.tx

+option(WITH_OLD_KEEPALIVE "Use old keepalive mechanism?" ON)
+if (WITH_OLD_KEEPALIVE)
+	add_definitions("-DWITH_OLD_KEEPALIVE")
+endif (WITH_OLD_KEEPALIVE)

I tryed to remove the full block (without knowing if it is the correct thing to do), it compiled successfully

 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;

Testing this code showed when I change the system time client disconnect anyway

daemon.notice mosquitto[1426]: 1744025901: Client edm-upT13J has exceeded timeout, disconnecting.
daemon.notice mosquitto[1426]: 1744025901: Client oi-0.stb70-001905103752.local has exceeded timeout, disconnecting.

Thanks for your help

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: mosquitto-brokerStatus: CompletedNothing further to be done with this issue, it can be closed by the requestor or committer.

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions