]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
submission: Simplify/clarify disconnection code flow
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 2 Mar 2021 13:46:11 +0000 (15:46 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 11 Mar 2021 11:19:09 +0000 (11:19 +0000)
client_disconnect() is now removed. Instead, client_destroy() now calls
smtp_server_connection_terminate() directly to cause a disconnection and
smtp_server_callbacks.conn_disconnect() handles the disconnection directly.
This same behavior happened earlier also, but it wasn't as clear.

src/submission/submission-client.c
src/submission/submission-client.h

index b071b18e9d6c99784b50f9351c20ba3b38810836..43299fb727f74115daf000c32b8c781eadb2d6d2 100644 (file)
@@ -308,7 +308,10 @@ client_default_destroy(struct client *client, const char *prefix,
                return;
        client->destroyed = TRUE;
 
-       client_disconnect(client, prefix, reason);
+       if (client->conn != NULL) {
+               smtp_server_connection_terminate(&client->conn,
+                       (prefix == NULL ? "4.0.0" : prefix), reason);
+       }
 
        submission_backends_destroy_all(client);
        array_free(&client->pending_backends);
@@ -422,10 +425,9 @@ static const char *client_stats(struct client *client)
        return str_c(str);
 }
 
-void client_disconnect(struct client *client, const char *enh_code,
-                      const char *reason)
+static void client_connection_disconnect(void *context, const char *reason)
 {
-       struct smtp_server_connection *conn;
+       struct client *client = context;
        const char *log_reason;
 
        if (client->disconnected)
@@ -451,26 +453,6 @@ void client_disconnect(struct client *client, const char *enh_code,
        i_info("Disconnect from %s: %s %s",
               client_remote_id(client),
               log_reason, client_stats(client));
-
-       conn = client->conn;
-       client->conn = NULL;
-       if (conn != NULL) {
-               smtp_server_connection_terminate(&conn,
-                       (enh_code == NULL ? "4.0.0" : enh_code), reason);
-       }
-}
-
-static void client_connection_disconnect(void *context, const char *reason)
-{
-       struct client *client = context;
-       struct smtp_server_connection *conn = client->conn;
-       const struct smtp_server_stats *stats;
-
-       if (conn != NULL) {
-               stats = smtp_server_connection_get_stats(conn);
-               client->stats = *stats;
-       }
-       client_disconnect(client, NULL, reason);
 }
 
 static void client_connection_free(void *context)
index 1c1c6ec80c4ecb69cd7877ff2f77543468017f44..e24efd8ef352162ef7602cbb7adc12fd236e5e4c 100644 (file)
@@ -144,8 +144,6 @@ struct client *client_create(int fd_in, int fd_out,
                             unsigned int pdata_len);
 void client_destroy(struct client *client, const char *prefix,
                    const char *reason) ATTR_NULL(2, 3);
-void client_disconnect(struct client *client, const char *prefix,
-                      const char *reason);
 
 typedef void (*client_input_callback_t)(struct client *context);