]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
indexer: Don't free worker_connection too early
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 31 Aug 2021 09:12:49 +0000 (12:12 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 15 Sep 2021 10:14:44 +0000 (10:14 +0000)
There's no need for the status callback anymore to free the connection.
It will be tracked automatically.

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 508c185512b595c23c722fc62e6ff1710157c213..9a7af6e28cf59da6d0d55b791732d1ff1af5a265 100644 (file)
@@ -108,8 +108,6 @@ static void worker_status_callback(int percentage, void *context)
 
        indexer_queue_request_finish(queue, &request,
                                     percentage == 100);
-       if (worker_pool != NULL) /* not in deinit */
-               worker_pool_release_connection(worker_pool, conn);
 
        /* if this was the last request for the connection, we can send more
           through it. delay it a bit, since we may be coming here from
index 90f536d2b2e3fba35832e100c76de27af10755a2..a9b9ae464c5ae4558f9f733603e6bfbca994c5a1 100644 (file)
@@ -25,8 +25,6 @@
 struct worker_connection {
        struct connection conn;
 
-       int refcount;
-
        indexer_status_callback_t *callback;
 
        char *request_username;
@@ -44,7 +42,7 @@ static void worker_connection_call_callback(struct worker_connection *worker,
                worker->request = NULL;
 }
 
-static void worker_connection_destroy(struct connection *conn)
+void worker_connection_destroy(struct connection *conn)
 {
        struct worker_connection *worker =
                container_of(conn, struct worker_connection, conn);
@@ -52,18 +50,6 @@ static void worker_connection_destroy(struct connection *conn)
        worker->request = NULL;
        i_free_and_null(worker->request_username);
        connection_deinit(conn);
-}
-
-void worker_connection_unref(struct connection **_conn)
-{
-       struct connection *conn = *_conn;
-       struct worker_connection *worker =
-               container_of(conn, struct worker_connection, conn);
-
-       i_assert(worker->refcount > 0);
-       if (--worker->refcount > 0)
-               return;
-       worker_connection_destroy(conn);
        i_free(conn);
 }
 
@@ -220,7 +206,6 @@ worker_connection_create(const char *socket_path,
        struct worker_connection *conn;
 
        conn = i_new(struct worker_connection, 1);
-       conn->refcount = 1;
        conn->callback = callback;
        connection_init_client_unix(list, &conn->conn, socket_path);
 
index 58fd050660272656becf9ce58761a5ab83996e31..f8d6c39d1aabd3f7a40ac464e35d85d6b8d886ff 100644 (file)
@@ -10,7 +10,7 @@ struct connection *
 worker_connection_create(const char *socket_path,
                         indexer_status_callback_t *callback,
                         struct connection_list *list);
-void worker_connection_unref(struct connection **_conn);
+void worker_connection_destroy(struct connection *conn);
 
 struct connection_list *worker_connection_list_create(void);
 
index 6367265885dc9f971a995589c1b8ffac64509c2e..16f8feb6e334d0c774be0edca96574e4aad1c1b1 100644 (file)
@@ -60,7 +60,7 @@ static int worker_pool_add_connection(struct worker_pool *pool,
        conn = worker_connection_create(pool->socket_path, pool->callback,
                                        pool->connection_list);
        if (connection_client_connect(conn) < 0) {
-               worker_connection_unref(&conn);
+               worker_connection_destroy(conn);
                return -1;
        }
 
@@ -99,12 +99,6 @@ bool worker_pool_get_connection(struct worker_pool *pool,
        return TRUE;
 }
 
-void worker_pool_release_connection(struct worker_pool *pool ATTR_UNUSED,
-                                   struct connection *conn)
-{
-       worker_connection_unref(&conn);
-}
-
 struct connection *
 worker_pool_find_username_connection(struct worker_pool *pool,
                                     const char *username)
index 057d67f37c2606a3cdafce09c62deb165afa3874..3f114d2024e21b1613c5f60f04a37ccc0fb052ea 100644 (file)
@@ -13,8 +13,6 @@ bool worker_pool_have_busy_connections(struct worker_pool *pool);
 
 bool worker_pool_get_connection(struct worker_pool *pool,
                                struct connection **conn_r);
-void worker_pool_release_connection(struct worker_pool *pool,
-                                   struct connection *conn);
 
 struct connection *
 worker_pool_find_username_connection(struct worker_pool *pool,