]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
indexer: Remove the concept of a "busy" connection
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 7 Sep 2021 14:00:07 +0000 (17:00 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 15 Sep 2021 10:14:44 +0000 (10:14 +0000)
All the connections are busy, since they are created for a new request and
they are disconnected when the request is done.

src/indexer/indexer.c
src/indexer/worker-connection.c
src/indexer/worker-connection.h
src/indexer/worker-pool.c
src/indexer/worker-pool.h

index 04ba8e6ed8025c8991bb961ce5ab27cb07bc22e4..9c63d79c27976afbfb3203d1553e860c0aaba485 100644 (file)
@@ -33,7 +33,7 @@ void indexer_refresh_proctitle(void)
 static bool idle_die(void)
 {
        return indexer_queue_is_empty(queue) &&
-               !worker_pool_have_busy_connections(worker_pool);
+               !worker_pool_have_connections(worker_pool);
 }
 
 static void client_connected(struct master_service_connection *conn)
@@ -63,7 +63,7 @@ static void queue_try_send_more(struct indexer_queue *queue)
        while ((request = indexer_queue_request_peek(queue)) != NULL) {
                conn = worker_pool_find_username_connection(worker_pool,
                                                            request->username);
-               if (conn != NULL && worker_connection_is_busy(conn)) {
+               if (conn != NULL) {
                        /* There is already a connection handling a request
                         * for this user. Move the request to the back of the
                         * queue and handle requests from other users.
@@ -77,7 +77,7 @@ static void queue_try_send_more(struct indexer_queue *queue)
                                first_moved_request = request;
                        indexer_queue_move_head_to_tail(queue);
                        continue;
-               } else if (conn == NULL) {
+               } else {
                        /* create a new connection to a worker */
                        if (!worker_pool_get_connection(worker_pool, &conn))
                                break;
index 02a07ebdce3e0156ff44d69116b955d5137eb459..f3661e50ae5bb944e0a60e7c7a3e4ff31dbdf716 100644 (file)
@@ -152,13 +152,6 @@ void worker_connection_request(struct connection *conn,
        } T_END;
 }
 
-bool worker_connection_is_busy(struct connection *conn)
-{
-       struct worker_connection *worker =
-               container_of(conn, struct worker_connection, conn);
-       return worker->request != NULL;
-}
-
 const char *worker_connection_get_username(struct connection *conn)
 {
        struct worker_connection *worker =
index a20e7af482fd1be61dcc73b6029676be21f5802e..e2818ce3d910847ed39ec3b2caf895920eeaa5ad 100644 (file)
@@ -30,8 +30,6 @@ unsigned int worker_connections_get_process_limit(void);
 void worker_connection_request(struct connection *conn,
                               struct indexer_request *request,
                               void *context);
-/* Returns TRUE if a request is being handled. */
-bool worker_connection_is_busy(struct connection *conn);
 /* Returns username of the currently pending requests,
    or NULL if there are none. */
 const char *worker_connection_get_username(struct connection *conn);
index 36fd16f1b653c88b47aada0ee21a90f2ba9f2c5e..e0de136aa5a0d5274e9bffceade21a603e180611 100644 (file)
@@ -46,13 +46,9 @@ void worker_pool_deinit(struct worker_pool **_pool)
        i_free(pool);
 }
 
-bool worker_pool_have_busy_connections(struct worker_pool *pool)
+bool worker_pool_have_connections(struct worker_pool *pool)
 {
-       struct connection *list;
-       for (list = pool->connection_list->connections; list != NULL; list = list->next)
-               if (worker_connection_is_busy(list))
-                       return TRUE;
-       return FALSE;
+       return pool->connection_list->connections != NULL;
 }
 
 static int worker_pool_add_connection(struct worker_pool *pool,
index bcab8287ae86bafcde42cc66a7611f1a998fb444..bf739bb6eb3b428d10c5924b369e7cdda2e1bf66 100644 (file)
@@ -11,7 +11,7 @@ worker_pool_init(const char *socket_path, indexer_status_callback_t *callback,
                 worker_available_callback_t *avail_callback);
 void worker_pool_deinit(struct worker_pool **pool);
 
-bool worker_pool_have_busy_connections(struct worker_pool *pool);
+bool worker_pool_have_connections(struct worker_pool *pool);
 
 bool worker_pool_get_connection(struct worker_pool *pool,
                                struct connection **conn_r);