]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
stats: Use the new listener type field to distinguish the various listener types.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Wed, 23 Nov 2022 01:33:06 +0000 (02:33 +0100)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Sun, 11 Dec 2022 21:58:50 +0000 (21:58 +0000)
src/stats/main.c
src/stats/stats-settings.c

index f63c3fd15b5e0dcd182f8cee1a62b8a8dca6f60a..67c9e7d7e2bb1f462712dca416df2f34b4bd6ee1 100644 (file)
@@ -18,30 +18,13 @@ time_t stats_startup_time;
 
 static const struct stats_settings *stats_settings;
 
-static bool client_is_writer(const char *path)
-{
-       const char *name, *suffix;
-
-       name = strrchr(path, '/');
-       if (name == NULL)
-               name = path;
-       else
-               name++;
-
-       suffix = strrchr(name, '-');
-       if (suffix == NULL)
-               suffix = name;
-       else
-               suffix++;
-
-       return strcmp(suffix, "writer") == 0;
-}
-
 static void client_connected(struct master_service_connection *conn)
 {
-       if (strcmp(conn->name, "http") == 0)
+       const char *type = master_service_connection_get_type(conn);
+
+       if (strcmp(type, "http") == 0)
                client_http_create(conn);
-       else if (client_is_writer(conn->name))
+       else if (strcmp(type, "writer") == 0)
                client_writer_create(conn->fd);
        else
                client_reader_create(conn->fd);
index 26404202b51f105d551961d5db775ac1e8d2d89b..4ca9abfe377506d78b25ca9042b2b9bd576dad50 100644 (file)
@@ -20,18 +20,21 @@ static bool stats_settings_check(void *_set, pool_t pool, const char **error_r);
 static struct file_listener_settings stats_unix_listeners_array[] = {
        {
                .path = "stats-reader",
+               .type = "reader",
                .mode = 0600,
                .user = "",
                .group = "",
        },
        {
                .path = "stats-writer",
+               .type = "writer",
                .mode = 0660,
                .user = "",
                .group = "$default_internal_group",
        },
        {
                .path = "login/stats-writer",
+               .type = "writer",
                .mode = 0600,
                .user = "$default_login_user",
                .group = "",