]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
indexer: Move functions from worker-pool to worker-connection
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 26 Jan 2022 18:10:16 +0000 (19:10 +0100)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Sun, 13 Feb 2022 10:23:26 +0000 (10:23 +0000)
src/indexer/worker-connection.c
src/indexer/worker-connection.h
src/indexer/worker-pool.c

index 32e218124e6e9d21719a2fe526fec6cf93fc8cb3..8c6f38107f03b4df57067bd9db9e7bf684e535f8 100644 (file)
@@ -220,3 +220,23 @@ int worker_connection_try_create(const char *socket_path,
        *conn_r = &conn->conn;
        return 1;
 }
+
+unsigned int worker_connections_get_count(struct connection_list *list)
+{
+       return list->connections_count;
+}
+
+struct connection *
+worker_connections_find_user(struct connection_list *list,
+                            const char *username)
+{
+       struct connection *conn;
+       const char *worker_user;
+
+       for (conn = list->connections; conn != NULL; conn = conn->next) {
+               worker_user = worker_connection_get_username(conn);
+               if (worker_user != NULL && strcmp(worker_user, username) == 0)
+                       return conn;
+       }
+       return NULL;
+}
index 1840cbb338a40803072e4f8babed021cd10d6c47..00bab2349d29a29042f72588eef1326c21038d47 100644 (file)
@@ -37,4 +37,9 @@ void worker_connection_request(struct connection *conn,
    or NULL if there are none. */
 const char *worker_connection_get_username(struct connection *conn);
 
+unsigned int worker_connections_get_count(struct connection_list *list);
+struct connection *
+worker_connections_find_user(struct connection_list *list,
+                            const char *username);
+
 #endif
index 3ebab8c83b7a9625f81c8ea81980a5d090f974f1..5b667706f810ffb64bdb5eef9ea10609fee41a96 100644 (file)
@@ -48,7 +48,7 @@ void worker_pool_deinit(struct worker_pool **_pool)
 
 bool worker_pool_have_connections(struct worker_pool *pool)
 {
-       return pool->connection_list->connections != NULL;
+       return worker_connections_get_count(pool->connection_list) > 0;
 }
 
 bool worker_pool_get_connection(struct worker_pool *pool,
@@ -63,13 +63,5 @@ struct connection *
 worker_pool_find_username_connection(struct worker_pool *pool,
                                     const char *username)
 {
-       struct connection *list;
-       const char *worker_user;
-
-       for (list = pool->connection_list->connections; list != NULL; list = list->next) {
-               worker_user = worker_connection_get_username(list);
-               if (worker_user != NULL && strcmp(worker_user, username) == 0)
-                       return list;
-       }
-       return NULL;
+       return worker_connections_find_user(pool->connection_list, username);
 }