# HG changeset patch # User Timo Sirainen # Date 1509110415 -10800 # Node ID 98408dc069375bec38b7a153a84bf851a6b2abdc # Parent 1789bf2a1e011fc4a54bff85ed3ea08e9dfffa0d director: Support multiple proxy-notify connections diff -r 1789bf2a1e01 -r 98408dc06937 src/director/main.c --- a/src/director/main.c Sun Nov 05 23:51:56 2017 +0200 +++ b/src/director/main.c Fri Oct 27 16:20:15 2017 +0300 @@ -36,7 +36,6 @@ }; static struct director *director; -static struct notify_connection *notify_conn; static struct timeout *to_proctitle_refresh; static ARRAY(enum director_socket_type) listener_socket_types; @@ -181,12 +180,8 @@ bool userdb; if (conn->fifo) { - if (notify_conn != NULL) { - i_error("Received another proxy-notify connection"); - return; - } master_service_client_connection_accept(conn); - notify_conn = notify_connection_init(director, conn->fd); + notify_connection_init(director, conn->fd); return; } @@ -298,8 +293,7 @@ { if (to_proctitle_refresh != NULL) timeout_remove(&to_proctitle_refresh); - if (notify_conn != NULL) - notify_connection_deinit(¬ify_conn); + notify_connections_deinit(); /* deinit doveadm connections before director, so it can clean up its pending work, such as abort user moves. */ doveadm_connections_deinit(); diff -r 1789bf2a1e01 -r 98408dc06937 src/director/notify-connection.c --- a/src/director/notify-connection.c Sun Nov 05 23:51:56 2017 +0200 +++ b/src/director/notify-connection.c Fri Oct 27 16:20:15 2017 +0300 @@ -2,6 +2,7 @@ #include "lib.h" #include "array.h" +#include "llist.h" #include "ioloop.h" #include "istream.h" #include "master-service.h" @@ -12,12 +13,18 @@ #include struct notify_connection { + struct notify_connection *prev, *next; + int fd; struct io *io; struct istream *input; struct director *dir; }; +static struct notify_connection *notify_connections = NULL; + +static void notify_connection_deinit(struct notify_connection **_conn); + static void notify_update_user(struct director *dir, struct mail_tag *tag, const char *username, unsigned int username_hash) { @@ -58,8 +65,7 @@ } } -struct notify_connection * -notify_connection_init(struct director *dir, int fd) +void notify_connection_init(struct director *dir, int fd) { struct notify_connection *conn; @@ -68,18 +74,27 @@ conn->dir = dir; conn->input = i_stream_create_fd(conn->fd, 1024, FALSE); conn->io = io_add(conn->fd, IO_READ, notify_connection_input, conn); - return conn; + DLLIST_PREPEND(¬ify_connections, conn); } -void notify_connection_deinit(struct notify_connection **_conn) +static void notify_connection_deinit(struct notify_connection **_conn) { struct notify_connection *conn = *_conn; *_conn = NULL; + DLLIST_REMOVE(¬ify_connections, conn); io_remove(&conn->io); i_stream_unref(&conn->input); if (close(conn->fd) < 0) i_error("close(notify connection) failed: %m"); i_free(conn); } + +void notify_connections_deinit(void) +{ + while (notify_connections != NULL) { + struct notify_connection *conn = notify_connections; + notify_connection_deinit(&conn); + } +} diff -r 1789bf2a1e01 -r 98408dc06937 src/director/notify-connection.h --- a/src/director/notify-connection.h Sun Nov 05 23:51:56 2017 +0200 +++ b/src/director/notify-connection.h Fri Oct 27 16:20:15 2017 +0300 @@ -3,7 +3,7 @@ struct director; -struct notify_connection *notify_connection_init(struct director *dir, int fd); -void notify_connection_deinit(struct notify_connection **conn); +void notify_connection_init(struct director *dir, int fd); +void notify_connections_deinit(void); #endif