]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
stats: Implement sending filter updates to connected processes.
authorsergey.kitov <sergey.kitov@open-xchange.com>
Mon, 10 May 2021 13:13:12 +0000 (16:13 +0300)
committersergey.kitov <sergey.kitov@open-xchange.com>
Fri, 3 Sep 2021 12:44:32 +0000 (15:44 +0300)
src/stats/client-writer.c
src/stats/client-writer.h

index 40795687547da68c827378a8f486d22c22d2c574..d949415038135f2474a4a4eea939c448e47e0650 100644 (file)
@@ -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);
 }
index dbb9e75856d523b2217c9b9a38ffdffba31ef0ce..a88de388f891acdd5d13a1786ae4c4c830886577 100644 (file)
@@ -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);