Simplify sys_tree calls further.

pull/2215/head
Roger Light 4 years ago
parent 4d644414ac
commit e82cee161f

@ -192,7 +192,7 @@ int mosquitto_main_loop(struct mosquitto__listener_sock *listensock, int listens
context__free_disused(); context__free_disused();
#ifdef WITH_SYS_TREE #ifdef WITH_SYS_TREE
if(db.config->sys_interval > 0){ if(db.config->sys_interval > 0){
sys_tree__update(db.config->sys_interval); sys_tree__update();
} }
#endif #endif

@ -680,7 +680,7 @@ int db__message_reconnect_reset(struct mosquitto *context);
bool db__ready_for_flight(struct mosquitto_msg_data *msgs, int qos); bool db__ready_for_flight(struct mosquitto_msg_data *msgs, int qos);
bool db__ready_for_queue(struct mosquitto *context, int qos, struct mosquitto_msg_data *msg_data); bool db__ready_for_queue(struct mosquitto *context, int qos, struct mosquitto_msg_data *msg_data);
void sys_tree__init(void); void sys_tree__init(void);
void sys_tree__update(int interval); void sys_tree__update(void);
int db__message_write_inflight_out_all(struct mosquitto *context); int db__message_write_inflight_out_all(struct mosquitto *context);
int db__message_write_inflight_out_latest(struct mosquitto *context); int db__message_write_inflight_out_latest(struct mosquitto *context);
int db__message_write_queued_out(struct mosquitto *context); int db__message_write_queued_out(struct mosquitto *context);

@ -157,7 +157,7 @@ static void calc_load(char *buf, const char *topic, bool initial, double exponen
* messages are sent for the $SYS hierarchy. * messages are sent for the $SYS hierarchy.
* 'start_time' is the result of time() that the broker was started at. * 'start_time' is the result of time() that the broker was started at.
*/ */
void sys_tree__update(int interval) void sys_tree__update(void)
{ {
static time_t last_update = 0; static time_t last_update = 0;
time_t uptime; time_t uptime;
@ -220,7 +220,9 @@ void sys_tree__update(int interval)
uint32_t len; uint32_t len;
bool initial_publish; bool initial_publish;
if(interval && db.now_s - interval > last_update){ if(db.config->sys_interval
&& db.now_s - db.config->sys_interval > last_update){
uptime = db.now_s - start_time; uptime = db.now_s - start_time;
len = (uint32_t)snprintf(buf, BUFLEN, "%d seconds", (int)uptime); len = (uint32_t)snprintf(buf, BUFLEN, "%d seconds", (int)uptime);
db__messages_easy_queue(NULL, "$SYS/broker/uptime", SYS_TREE_QOS, len, buf, 1, 60, NULL); db__messages_easy_queue(NULL, "$SYS/broker/uptime", SYS_TREE_QOS, len, buf, 1, 60, NULL);

Loading…
Cancel
Save