]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lmtp: Simplify/clarify disconnection code flow
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 2 Mar 2021 14:37:30 +0000 (16:37 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 11 Mar 2021 11:19:09 +0000 (11:19 +0000)
This is similar to the earlier submission commit.

src/lmtp/lmtp-client.c
src/lmtp/lmtp-client.h

index c55e4f78013737056ff4a70eea1aea970c2eb173..196ee6d9454f73eab2d364e02bcc69a421f98757 100644 (file)
@@ -264,8 +264,10 @@ client_default_destroy(struct client *client, const char *enh_code,
                return;
        client->destroyed = TRUE;
 
-       client_disconnect(client, enh_code, reason);
-
+       if (client->conn != NULL) {
+               smtp_server_connection_terminate(&client->conn,
+                       (enh_code == NULL ? "4.0.0" : enh_code), reason);
+       }
        clients_count--;
        DLLIST_REMOVE(&clients, client);
 
@@ -280,26 +282,6 @@ client_default_destroy(struct client *client, const char *enh_code,
        master_service_client_connection_destroyed(master_service);
 }
 
-void client_disconnect(struct client *client, const char *enh_code,
-                      const char *reason)
-{
-       struct smtp_server_connection *conn = client->conn;
-
-       if (client->disconnected)
-               return;
-       client->disconnected = TRUE;
-
-       if (reason == NULL)
-               reason = "Connection closed";
-       e_info(client->event, "Disconnect from %s: %s",
-              client_remote_id(client), reason);
-
-       if (conn != NULL) {
-               smtp_server_connection_terminate(
-                       &conn, (enh_code == NULL ? "4.0.0" : enh_code), reason);
-       }
-}
-
 static void
 client_connection_trans_start(void *context,
                              struct smtp_server_transaction *trans)
@@ -375,7 +357,14 @@ static void client_connection_disconnect(void *context, const char *reason)
 {
        struct client *client = (struct client *)context;
 
-       client_disconnect(client, NULL, reason);
+       if (client->disconnected)
+               return;
+       client->disconnected = TRUE;
+
+       if (reason == NULL)
+               reason = "Connection closed";
+       e_info(client->event, "Disconnect from %s: %s",
+              client_remote_id(client), reason);
 }
 
 static void client_connection_free(void *context)
index 175a5ec17b6b44447ebe59fb608f5d986077f910..b3c463dd90254e7b4f65ae4b4c716c28c3e95111 100644 (file)
@@ -116,8 +116,6 @@ struct client *client_create(int fd_in, int fd_out,
                             const struct master_service_connection *conn);
 void client_destroy(struct client *client, const char *enh_code,
                    const char *reason) ATTR_NULL(2, 3);
-void client_disconnect(struct client *client, const char *enh_code,
-                      const char *reason) ATTR_NULL(2, 3);
 
 void client_state_reset(struct client *client);
 void client_update_data_state(struct client *client, const char *new_args);