Cannot compile mosquitto 2.0.21 with option WITH_OLD_KEEPALIVE set
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
Thanks for the report. I believe the underlying problem with the keepalive was actually caused by #3238. That is fixed for 2.0.22, I encourage you to test it out.
In the meantime, I've fixed the compilation using WITH_OLD_KEEPALIVE.