]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: auth-worker-client - Internalize auth_worker_client
authorAki Tuomi <aki.tuomi@dovecot.fi>
Mon, 26 Nov 2018 16:57:02 +0000 (18:57 +0200)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Wed, 28 Nov 2018 13:35:41 +0000 (15:35 +0200)
src/auth/auth-worker-client.c
src/auth/auth-worker-client.h
src/auth/main.c

index db183eb9656bfd889831a061908805a3e6c95fc4..dd5c3753a5af2d852cde6a1daec6c3d5ff6a9b05 100644 (file)
@@ -46,11 +46,13 @@ struct auth_worker_list_context {
        bool sending, sent, done;
 };
 
-struct auth_worker_client *auth_worker_client;
+static struct auth_worker_client *auth_worker_client = NULL;
 static bool auth_worker_client_error = FALSE;
 
 static void auth_worker_input(struct auth_worker_client *client);
 static int auth_worker_output(struct auth_worker_client *client);
+static void auth_worker_client_destroy(struct auth_worker_client **_client);
+static void auth_worker_client_unref(struct auth_worker_client **_client);
 
 void auth_worker_refresh_proctitle(const char *state)
 {
@@ -824,7 +826,7 @@ auth_worker_client_create(struct auth *auth,
        return client;
 }
 
-void auth_worker_client_destroy(struct auth_worker_client **_client)
+static void auth_worker_client_destroy(struct auth_worker_client **_client)
 {
        struct auth_worker_client *client = *_client;
 
@@ -847,7 +849,7 @@ void auth_worker_client_destroy(struct auth_worker_client **_client)
        master_service_client_connection_destroyed(master_service);
 }
 
-void auth_worker_client_unref(struct auth_worker_client **_client)
+static void auth_worker_client_unref(struct auth_worker_client **_client)
 {
        struct auth_worker_client *client = *_client;
 
@@ -891,3 +893,15 @@ void auth_worker_client_send_shutdown(void)
                o_stream_nsend_str(auth_worker_client->output, "SHUTDOWN\n");
        auth_worker_refresh_proctitle(CLIENT_STATE_STOP);
 }
+
+void auth_worker_connections_destroy_all(void)
+{
+       if (auth_worker_client == NULL)
+               return;
+       auth_worker_client_destroy(&auth_worker_client);
+}
+
+bool auth_worker_has_client(void)
+{
+       return auth_worker_client != NULL;
+}
index 99ec8e6a14c6184ce364833c4c6c721e8d620248..8c8ea90c34de5b1a09165a529db9282993139f6f 100644 (file)
@@ -6,18 +6,18 @@
 #define AUTH_WORKER_MAX_LINE_LENGTH 8192
 
 struct master_service_connection;
-extern struct auth_worker_client *auth_worker_client;
 
 struct auth_worker_client *
 auth_worker_client_create(struct auth *auth,
                          const struct master_service_connection *master_conn);
 bool auth_worker_auth_request_new(struct auth_worker_client *client, unsigned int id,
                                  const char *const *args, struct auth_request **request_r);
-void auth_worker_client_destroy(struct auth_worker_client **client);
-void auth_worker_client_unref(struct auth_worker_client **client);
 
+bool auth_worker_has_client(void);
 void auth_worker_client_send_error(void);
 void auth_worker_client_send_success(void);
 void auth_worker_client_send_shutdown(void);
 
+void auth_worker_connections_destroy_all(void);
+
 #endif
index cc7fb3442cea14f8e3f335d562b57842dc6a2be9..2dbf9e176bf650facdb0791a82feb4f2a289422c 100644 (file)
@@ -279,9 +279,7 @@ static void main_deinit(void)
        auth_client_connections_destroy_all();
        auth_master_connections_destroy_all();
        auth_postfix_connections_destroy_all();
-
-       if (auth_worker_client != NULL)
-               auth_worker_client_destroy(&auth_worker_client);
+       auth_worker_connections_destroy_all();
 
        auth_policy_deinit();
        mech_register_deinit(&mech_reg);
@@ -308,7 +306,7 @@ static void main_deinit(void)
 
 static void worker_connected(struct master_service_connection *conn)
 {
-       if (auth_worker_client != NULL) {
+       if (auth_worker_has_client()) {
                i_error("Auth workers can handle only a single client");
                return;
        }