]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap-urlauth: imap-urlauth-worker-client - Rename functions to have the proper prefix.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Thu, 1 Dec 2022 22:26:48 +0000 (23:26 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 24 Mar 2023 07:14:54 +0000 (07:14 +0000)
src/imap-urlauth/imap-urlauth-client.c
src/imap-urlauth/imap-urlauth-worker-client.c
src/imap-urlauth/imap-urlauth-worker-client.h

index ab36a965124fa44799142402e9162911f3b58679..5b55904276e0689daf7a6fa5193727c1e5d2c141 100644 (file)
@@ -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);
 
index 8c6a7cc0ec32a8cdec81e1775023d1be8f9ac4c3..0a945353925763e46e14a95d1555e47364b14161 100644 (file)
@@ -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;
        }
 
index 8896ae1cf66408640a276b89c2a1c3396ca17f57..70304ab013f8a2b11eaa0da2f9734b5fbbc8b0a8 100644 (file)
@@ -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