From: sergey.kitov Date: Mon, 10 May 2021 13:13:12 +0000 (+0300) Subject: stats: Implement sending filter updates to connected processes. X-Git-Tag: 2.3.17~156 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=adbbd40458ea6847c10ac2e3edca4410bda293b3;p=thirdparty%2Fdovecot%2Fcore.git stats: Implement sending filter updates to connected processes. --- diff --git a/src/stats/client-writer.c b/src/stats/client-writer.c index 4079568754..d949415038 100644 --- a/src/stats/client-writer.c +++ b/src/stats/client-writer.c @@ -16,6 +16,8 @@ #include "stats-settings.h" #include "client-writer.h" +#define STATS_UPDATE_CLIENTS_DELAY_MSECS 1000 + struct stats_event { struct stats_event *prev, *next; @@ -30,6 +32,7 @@ struct writer_client { HASH_TABLE(struct stats_event *, struct stats_event *) events_hash; }; +static struct timeout *to_update_clients; static struct connection_list *writer_clients = NULL; static void client_writer_send_handshake(struct writer_client *client) @@ -316,6 +319,27 @@ static const struct connection_vfuncs client_vfuncs = { .input_args = writer_client_input_args, }; +static void +client_writer_update_connections_internal(void *context ATTR_UNUSED) +{ + struct connection *conn; + for (conn = writer_clients->connections; conn != NULL; conn = conn->next) { + struct writer_client *client = + container_of(conn, struct writer_client, conn); + client_writer_send_handshake(client); + } + timeout_remove(&to_update_clients); +} + +void client_writer_update_connections(void) +{ + if (to_update_clients != NULL) + return; + to_update_clients = timeout_add(STATS_UPDATE_CLIENTS_DELAY_MSECS, + client_writer_update_connections_internal, + NULL); +} + void client_writers_init(void) { writer_clients = connection_list_init(&client_set, &client_vfuncs); @@ -323,5 +347,6 @@ void client_writers_init(void) void client_writers_deinit(void) { + timeout_remove(&to_update_clients); connection_list_deinit(&writer_clients); } diff --git a/src/stats/client-writer.h b/src/stats/client-writer.h index dbb9e75856..a88de388f8 100644 --- a/src/stats/client-writer.h +++ b/src/stats/client-writer.h @@ -5,6 +5,8 @@ struct stats_metrics; void client_writer_create(int fd); +void client_writer_update_connections(void); + void client_writers_init(void); void client_writers_deinit(void);