From 8ab01a473809576ee57ae4dfdcb77ced300b18a6 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 1 Apr 2016 00:18:27 +0200 Subject: Fix off-by-one in update interval computation The sys tree is programmed to be updated every 10 seconds but in fact due to an off-by-one error in the time computation it's effectively updated every 11 seconds. The operation should indeed be performed each time the difference equals the interval. --- src/sys_tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sys_tree.c b/src/sys_tree.c index 2f00630..e28c759 100644 --- a/src/sys_tree.c +++ b/src/sys_tree.c @@ -187,7 +187,7 @@ void mqtt3_db_sys_update(struct mosquitto_db *db, int interval, time_t start_tim now = mosquitto_time(); - if(interval && now - interval > last_update){ + if(interval && now - interval >= last_update){ uptime = now - start_time; snprintf(buf, BUFLEN, "%d seconds", (int)uptime); mqtt3_db_messages_easy_queue(db, NULL, "$SYS/broker/uptime", 2, strlen(buf), buf, 1); -- 1.7.12.1