]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm: server-connection - Replace "print pending" server list with connection...
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 29 Jul 2021 16:01:44 +0000 (19:01 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 17 Jan 2022 11:52:09 +0000 (13:52 +0200)
This is in preparation for removing dependency on doveadm_server.

src/doveadm/server-connection.c

index f5632a25112bac9791925323b9c4a7e51ddbc58d..2b7b763dea423fb79d92819445895dc86ba21f2f 100644 (file)
@@ -58,46 +58,31 @@ struct server_connection {
 };
 
 static struct server_connection *printing_conn = NULL;
-static ARRAY(struct doveadm_server *) print_pending_servers = ARRAY_INIT;
+static ARRAY(struct server_connection *) print_pending_connections = ARRAY_INIT;
 
 static bool server_connection_input_one(struct server_connection *conn);
 static int server_connection_init_ssl(struct server_connection *conn,
                                      const char **error_r);
 static void server_connection_destroy(struct server_connection **_conn);
 
-static void server_set_print_pending(struct doveadm_server *server)
+static void server_set_print_pending(struct server_connection *conn)
 {
-       struct doveadm_server *pending_server;
-
-       if (!array_is_created(&print_pending_servers))
-               i_array_init(&print_pending_servers, 16);
-       array_foreach_elem(&print_pending_servers, pending_server) {
-               if (pending_server == server)
-                       return;
-       }
-       array_push_back(&print_pending_servers, &server);
-}
-
-static void server_print_connection_released(struct doveadm_server *server)
-{
-       struct connection *conn;
-
-       conn = server->connections->connections;
-       for (; conn != NULL; conn = conn->next)
-               connection_input_resume(conn);
+       if (!array_is_created(&print_pending_connections))
+               i_array_init(&print_pending_connections, 16);
+       array_push_back(&print_pending_connections, &conn);
 }
 
 static void print_connection_released(void)
 {
-       struct doveadm_server *server;
+       struct server_connection *conn;
 
        printing_conn = NULL;
-       if (!array_is_created(&print_pending_servers))
+       if (!array_is_created(&print_pending_connections))
                return;
 
-       array_foreach_elem(&print_pending_servers, server)
-               server_print_connection_released(server);
-       array_free(&print_pending_servers);
+       array_foreach_elem(&print_pending_connections, conn)
+               connection_input_resume(&conn->conn);
+       array_free(&print_pending_connections);
 }
 
 static int server_connection_send_cmd_input_more(struct server_connection *conn)
@@ -209,7 +194,7 @@ server_handle_input(struct server_connection *conn,
        } else {
                /* someone else is printing. don't continue until it
                   goes away */
-               server_set_print_pending(conn->server);
+               server_set_print_pending(conn);
                io_remove(&conn->conn.io);
                return;
        }