Move static sys tree entries to sys_tree.c.
This commit is contained in:
parent
a04662265a
commit
43bcf6799c
@ -197,9 +197,6 @@ int main(int argc, char *argv[])
|
||||
int listensock_count = 0;
|
||||
int listensock_index = 0;
|
||||
struct mosquitto__config config;
|
||||
#ifdef WITH_SYS_TREE
|
||||
char buf[1024];
|
||||
#endif
|
||||
int i, j;
|
||||
FILE *pid;
|
||||
int listener_max;
|
||||
@ -281,13 +278,7 @@ int main(int argc, char *argv[])
|
||||
if(rc) return rc;
|
||||
|
||||
#ifdef WITH_SYS_TREE
|
||||
if(config.sys_interval > 0){
|
||||
/* Set static $SYS messages */
|
||||
snprintf(buf, 1024, "mosquitto version %s", VERSION);
|
||||
db__messages_easy_queue(&int_db, NULL, "$SYS/broker/version", 2, strlen(buf), buf, 1);
|
||||
snprintf(buf, 1024, "%s", TIMESTAMP);
|
||||
db__messages_easy_queue(&int_db, NULL, "$SYS/broker/timestamp", 2, strlen(buf), buf, 1);
|
||||
}
|
||||
sys__init(&int_db);
|
||||
#endif
|
||||
|
||||
listener_max = -1;
|
||||
|
@ -510,6 +510,7 @@ void db__msg_store_deref(struct mosquitto_db *db, struct mosquitto_msg_store **s
|
||||
void db__msg_store_clean(struct mosquitto_db *db);
|
||||
int db__message_reconnect_reset(struct mosquitto_db *db, struct mosquitto *context);
|
||||
void db__vacuum(void);
|
||||
void sys__init(struct mosquitto_db *db);
|
||||
void sys__update(struct mosquitto_db *db, int interval, time_t start_time);
|
||||
|
||||
/* ============================================================
|
||||
|
@ -40,6 +40,21 @@ int g_clients_expired = 0;
|
||||
unsigned int g_socket_connections = 0;
|
||||
unsigned int g_connection_count = 0;
|
||||
|
||||
void sys__init(struct mosquitto_db *db)
|
||||
{
|
||||
char buf[64];
|
||||
|
||||
if(db->config->sys_interval == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set static $SYS messages */
|
||||
snprintf(buf, 64, "mosquitto version %s", VERSION);
|
||||
db__messages_easy_queue(db, NULL, "$SYS/broker/version", 2, strlen(buf), buf, 1);
|
||||
snprintf(buf, 64, "%s", TIMESTAMP);
|
||||
db__messages_easy_queue(db, NULL, "$SYS/broker/timestamp", 2, strlen(buf), buf, 1);
|
||||
}
|
||||
|
||||
static void sys__update_clients(struct mosquitto_db *db, char *buf)
|
||||
{
|
||||
static unsigned int client_count = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user