There's no need for the status callback anymore to free the connection.
It will be tracked automatically.
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
struct worker_connection {
struct connection conn;
- int refcount;
-
indexer_status_callback_t *callback;
char *request_username;
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);
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);
}
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);
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);
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;
}
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)
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,