From 788a0754cfd38dcfec1902844b085e4e84cfe7e6 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 12 Nov 2009 18:28:39 -0500 Subject: [PATCH] auth worker: Don't start breaking if connection to auth master dies. --HG-- branch : HEAD --- src/auth/auth-worker-client.c | 5 +++++ src/auth/auth-worker-client.h | 2 ++ src/auth/main.c | 9 ++++----- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/auth/auth-worker-client.c b/src/auth/auth-worker-client.c index 4e69219dd4..5aba7f8450 100644 --- a/src/auth/auth-worker-client.c +++ b/src/auth/auth-worker-client.c @@ -33,6 +33,8 @@ struct auth_worker_list_context { bool sending, sent, done; }; +struct auth_worker_client *auth_worker_client; + static void auth_worker_input(struct auth_worker_client *client); static int auth_worker_output(struct auth_worker_client *client); @@ -599,6 +601,8 @@ auth_worker_client_create(struct auth *auth, int fd) client->output = o_stream_create_fd(fd, (size_t)-1, FALSE); o_stream_set_flush_callback(client->output, auth_worker_output, client); client->io = io_add(fd, IO_READ, auth_worker_input, client); + + auth_worker_client = client; return client; } @@ -620,6 +624,7 @@ void auth_worker_client_destroy(struct auth_worker_client **_client) client->fd = -1; auth_worker_client_unref(&client); + auth_worker_client = NULL; master_service_client_connection_destroyed(master_service); } diff --git a/src/auth/auth-worker-client.h b/src/auth/auth-worker-client.h index 449b55a653..d683c5f83a 100644 --- a/src/auth/auth-worker-client.h +++ b/src/auth/auth-worker-client.h @@ -3,6 +3,8 @@ #define AUTH_WORKER_MAX_LINE_LENGTH 8192 +extern struct auth_worker_client *auth_worker_client; + struct auth_worker_client *auth_worker_client_create(struct auth *auth, int fd); void auth_worker_client_destroy(struct auth_worker_client **client); void auth_worker_client_unref(struct auth_worker_client **client); diff --git a/src/auth/main.c b/src/auth/main.c index 0a7772ac79..1e1989d8cf 100644 --- a/src/auth/main.c +++ b/src/auth/main.c @@ -35,7 +35,6 @@ time_t process_start_time; static struct module *modules = NULL; static struct auth *auth; -static struct auth_worker_client *worker_client; static ARRAY_DEFINE(listen_fd_types, enum auth_socket_type); static void main_preinit(struct auth_settings *set) @@ -89,8 +88,8 @@ static void main_init(void) static void main_deinit(void) { - if (worker_client != NULL) - auth_worker_client_destroy(&worker_client); + if (auth_worker_client != NULL) + auth_worker_client_destroy(&auth_worker_client); else auth_request_handler_flush_failures(TRUE); @@ -113,12 +112,12 @@ static void main_deinit(void) static void worker_connected(const struct master_service_connection *conn) { - if (worker_client != NULL) { + if (auth_worker_client != NULL) { i_error("Auth workers can handle only a single client"); (void)close(conn->fd); return; } - worker_client = auth_worker_client_create(auth, conn->fd); + (void)auth_worker_client_create(auth, conn->fd); } static void client_connected(const struct master_service_connection *conn) -- 2.47.3