]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth worker: Don't start breaking if connection to auth master dies.
authorTimo Sirainen <tss@iki.fi>
Thu, 12 Nov 2009 23:28:39 +0000 (18:28 -0500)
committerTimo Sirainen <tss@iki.fi>
Thu, 12 Nov 2009 23:28:39 +0000 (18:28 -0500)
--HG--
branch : HEAD

src/auth/auth-worker-client.c
src/auth/auth-worker-client.h
src/auth/main.c

index 4e69219dd4b992cc7b86a2e89fe50986edf1c929..5aba7f8450b80acc3bc31a871938099df5b9340f 100644 (file)
@@ -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);
 }
 
index 449b55a653a890b06f7d48f003a9bd363cd500a4..d683c5f83aeff71b18c177e2438443588710cb14 100644 (file)
@@ -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);
index 0a7772ac79cce0df6a6754efe8d1184c1c857ce6..1e1989d8cf65f3dd35d5dd9d9ee967847c15ba58 100644 (file)
@@ -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)