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)
{
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;
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;
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;
+}
#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
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);
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;
}