From: Stephan Bosch Date: Thu, 1 Dec 2022 22:26:48 +0000 (+0100) Subject: imap-urlauth: imap-urlauth-worker-client - Rename functions to have the proper prefix. X-Git-Tag: 2.4.0~2875 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9798b8e4da39de03a539199af39423a2c292e829;p=thirdparty%2Fdovecot%2Fcore.git imap-urlauth: imap-urlauth-worker-client - Rename functions to have the proper prefix. --- diff --git a/src/imap-urlauth/imap-urlauth-client.c b/src/imap-urlauth/imap-urlauth-client.c index ab36a96512..5b55904276 100644 --- a/src/imap-urlauth/imap-urlauth-client.c +++ b/src/imap-urlauth/imap-urlauth-client.c @@ -63,7 +63,7 @@ int client_create(const char *service, const char *username, event_set_append_log_prefix(client->event, t_strdup_printf( "user %s: ", username)); - if (client_worker_connect(client) < 0) { + if (imap_urlauth_worker_client_connect(client) < 0) { event_unref(&client->event); i_free(client); return -1; @@ -138,7 +138,7 @@ void client_destroy(struct client *client, const char *reason) timeout_remove(&client->to_destroy); - client_worker_disconnect(client); + imap_urlauth_worker_client_disconnect(client); o_stream_destroy(&client->output); diff --git a/src/imap-urlauth/imap-urlauth-worker-client.c b/src/imap-urlauth/imap-urlauth-worker-client.c index 8c6a7cc0ec..0a94535392 100644 --- a/src/imap-urlauth/imap-urlauth-worker-client.c +++ b/src/imap-urlauth/imap-urlauth-worker-client.c @@ -18,7 +18,7 @@ static void client_worker_input(struct client *wclient); -int client_worker_connect(struct client *wclient) +int imap_urlauth_worker_client_connect(struct client *wclient) { struct client *client = wclient; static const char handshake[] = "VERSION\timap-urlauth-worker\t2\t0\n"; @@ -64,7 +64,7 @@ int client_worker_connect(struct client *wclient) "fd_send(%s, %d) failed to send byte", socket_path, wclient->fd_ctrl); } - client_worker_disconnect(wclient); + imap_urlauth_worker_client_disconnect(wclient); return -1; } @@ -74,7 +74,7 @@ int client_worker_connect(struct client *wclient) if (o_stream_send_str(wclient->ctrl_output, handshake) < 0) { e_error(wclient->event, "Error sending handshake to imap-urlauth worker: %m"); - client_worker_disconnect(wclient); + imap_urlauth_worker_client_disconnect(wclient); return -1; } @@ -85,7 +85,7 @@ int client_worker_connect(struct client *wclient) return 0; } -void client_worker_disconnect(struct client *wclient) +void imap_urlauth_worker_client_disconnect(struct client *wclient) { wclient->worker_state = IMAP_URLAUTH_WORKER_STATE_INACTIVE; @@ -98,6 +98,12 @@ void client_worker_disconnect(struct client *wclient) } } +static void +imap_urlauth_worker_client_error(struct client *wclient, const char *error) +{ + client_disconnect(wclient, error); +} + static int client_worker_input_line(struct client *wclient, const char *response) { @@ -111,7 +117,8 @@ client_worker_input_line(struct client *wclient, const char *response) switch (wclient->worker_state) { case IMAP_URLAUTH_WORKER_STATE_INACTIVE: if (strcasecmp(response, "OK") != 0) { - client_disconnect(wclient, "Worker handshake failed"); + imap_urlauth_worker_client_error( + wclient, "Worker handshake failed"); return -1; } wclient->worker_state = IMAP_URLAUTH_WORKER_STATE_CONNECTED; @@ -139,7 +146,7 @@ client_worker_input_line(struct client *wclient, const char *response) str_data(str), str_len(str)); i_assert(ret < 0 || (size_t)ret == str_len(str)); if (ret < 0) { - client_disconnect(wclient, + imap_urlauth_worker_client_error(wclient, "Failed to send ACCESS control command to worker"); return -1; } @@ -147,7 +154,7 @@ client_worker_input_line(struct client *wclient, const char *response) case IMAP_URLAUTH_WORKER_STATE_CONNECTED: if (strcasecmp(response, "OK") != 0) { - client_disconnect(wclient, + imap_urlauth_worker_client_error(wclient, "Failed to negotiate access parameters"); return -1; } @@ -161,7 +168,7 @@ client_worker_input_line(struct client *wclient, const char *response) restart = FALSE; } else if (strcasecmp(response, "FINISHED") != 0) { /* unknown response */ - client_disconnect(wclient, + imap_urlauth_worker_client_error(wclient, "Worker finished with unknown response"); return -1; } @@ -170,9 +177,9 @@ client_worker_input_line(struct client *wclient, const char *response) if (restart) { /* connect to new worker for accessing different user */ - client_worker_disconnect(wclient); - if (client_worker_connect(wclient) < 0) { - client_disconnect(wclient, + imap_urlauth_worker_client_disconnect(wclient); + if (imap_urlauth_worker_client_connect(wclient) < 0) { + imap_urlauth_worker_client_error(wclient, "Failed to connect to new worker"); return -1; } @@ -180,7 +187,8 @@ client_worker_input_line(struct client *wclient, const char *response) /* indicate success of "END" command */ client_send_line(client, "OK"); } else { - client_disconnect(wclient, "Client disconnected"); + imap_urlauth_worker_client_error( + wclient, "Client disconnected"); } return -1; default: @@ -196,18 +204,21 @@ static void client_worker_input(struct client *wclient) if (input->closed) { /* disconnected */ - client_disconnect(wclient, "Worker disconnected unexpectedly"); + imap_urlauth_worker_client_error( + wclient, "Worker disconnected unexpectedly"); return; } switch (i_stream_read(input)) { case -1: /* disconnected */ - client_disconnect(wclient, "Worker disconnected unexpectedly"); + imap_urlauth_worker_client_error( + wclient, "Worker disconnected unexpectedly"); return; case -2: /* input buffer full */ - client_disconnect(wclient, "Worker sent too large input"); + imap_urlauth_worker_client_error( + wclient, "Worker sent too large input"); return; } diff --git a/src/imap-urlauth/imap-urlauth-worker-client.h b/src/imap-urlauth/imap-urlauth-worker-client.h index 8896ae1cf6..70304ab013 100644 --- a/src/imap-urlauth/imap-urlauth-worker-client.h +++ b/src/imap-urlauth/imap-urlauth-worker-client.h @@ -3,7 +3,7 @@ #include "imap-urlauth-worker-common.h" -int client_worker_connect(struct client *wclient); -void client_worker_disconnect(struct client *wclient); +int imap_urlauth_worker_client_connect(struct client *wclient); +void imap_urlauth_worker_client_disconnect(struct client *wclient); #endif