]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-master: If stats process wants no events, send nothing to it
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 23 May 2018 12:14:50 +0000 (15:14 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 25 May 2018 07:28:23 +0000 (07:28 +0000)
Instead of sending everything to it..

src/lib-master/stats-client.c

index 2c007872bb38abdb8919e3e4af5d5e5cf4fb3b75..caff0f5253cee134cc06cdf979dfe23785274c8b 100644 (file)
@@ -34,6 +34,10 @@ client_handshake_filter(const char *const *args, struct event_filter **filter_r,
                *error_r = "Expected FILTER";
                return -1;
        }
+       if (args[1] == NULL || args[1][0] == '\0') {
+               *filter_r = NULL;
+               return 0;
+       }
 
        *filter_r = event_filter_create();
        if (!event_filter_import_unescaped(*filter_r, args+1, error_r)) {
@@ -58,6 +62,10 @@ stats_client_handshake(struct stats_client *client, const char *const *args)
        client->handshake_received_at_least_once = TRUE;
        if (client->ioloop != NULL)
                io_loop_stop(client->ioloop);
+       if (filter == NULL) {
+               /* stats process wants nothing to be sent to it */
+               return 1;
+       }
 
        if (client->filter != NULL) {
                /* Filter is already set. It becomes a bit complicated to
@@ -200,7 +208,7 @@ static void
 stats_client_send_event(struct stats_client *client, struct event *event,
                        const struct failure_context *ctx)
 {
-       if (!client->handshaked ||
+       if (!client->handshaked || client->filter == NULL ||
            !event_filter_match(client->filter, event, ctx))
                return;