};
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;
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;
}
{
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();
#include "lib.h"
#include "array.h"
+#include "llist.h"
#include "ioloop.h"
#include "istream.h"
#include "master-service.h"
#include <unistd.h>
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)
{
}
}
-struct notify_connection *
-notify_connection_init(struct director *dir, int fd)
+void notify_connection_init(struct director *dir, int fd)
{
struct notify_connection *conn;
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);
+ }
+}