changeset 10318:1c29c69248e0 HEAD

auth worker: Don't start breaking if connection to auth master dies.
author Timo Sirainen <tss@iki.fi>
date Thu, 12 Nov 2009 18:28:39 -0500
parents 8d47c9dbe9cb
children 506fba223006
files src/auth/auth-worker-client.c src/auth/auth-worker-client.h src/auth/main.c
diffstat 3 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/auth-worker-client.c	Thu Nov 12 16:46:55 2009 -0500
+++ b/src/auth/auth-worker-client.c	Thu Nov 12 18:28:39 2009 -0500
@@ -33,6 +33,8 @@
 	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 @@
 	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 @@
 	client->fd = -1;
 	auth_worker_client_unref(&client);
 
+	auth_worker_client = NULL;
 	master_service_client_connection_destroyed(master_service);
 }
 
--- a/src/auth/auth-worker-client.h	Thu Nov 12 16:46:55 2009 -0500
+++ b/src/auth/auth-worker-client.h	Thu Nov 12 18:28:39 2009 -0500
@@ -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);
--- a/src/auth/main.c	Thu Nov 12 16:46:55 2009 -0500
+++ b/src/auth/main.c	Thu Nov 12 18:28:39 2009 -0500
@@ -35,7 +35,6 @@
 
 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_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 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)