]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: client: Move creation of connection object to a separate function.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sun, 23 Sep 2018 17:32:11 +0000 (19:32 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 12 Feb 2019 13:41:05 +0000 (15:41 +0200)
src/lib-smtp/smtp-client-connection.c

index e54c720d2efc1cad4595c6ee433340ec122ba15f..2f320b9c149b9e032b121b6bab4ac2b0c0cd06a1 100644 (file)
@@ -1720,11 +1720,10 @@ void smtp_client_connection_disconnect(struct smtp_client_connection *conn)
        }
 }
 
-struct smtp_client_connection *
-smtp_client_connection_create(struct smtp_client *client,
-       enum smtp_protocol protocol, const char *host, in_port_t port,
-       enum smtp_client_connection_ssl_mode ssl_mode,
-       const struct smtp_client_settings *set)
+static struct smtp_client_connection *
+smtp_client_connection_do_create(struct smtp_client *client, const char *name,
+                                enum smtp_protocol protocol,
+                                const struct smtp_client_settings *set)
 {
        static unsigned int id = 0;
        struct smtp_client_connection *conn;
@@ -1738,10 +1737,7 @@ smtp_client_connection_create(struct smtp_client *client,
        conn->client = client;
        conn->id = id++;
        conn->protocol = protocol;
-       conn->host = p_strdup(conn->pool, host);
-       conn->port = port;
-       conn->ssl_mode = ssl_mode;
-       conn->conn.name = i_strdup_printf("%s:%u", host, port);
+       conn->conn.name = i_strdup(name);
 
        conn->set = client->set;
        if (set != NULL) {
@@ -1819,6 +1815,23 @@ smtp_client_connection_create(struct smtp_client *client,
        return conn;
 }
 
+struct smtp_client_connection *
+smtp_client_connection_create(struct smtp_client *client,
+       enum smtp_protocol protocol, const char *host, in_port_t port,
+       enum smtp_client_connection_ssl_mode ssl_mode,
+       const struct smtp_client_settings *set)
+{
+       struct smtp_client_connection *conn;
+       const char *name = t_strdup_printf("%s:%u", host, port);
+
+       conn = smtp_client_connection_do_create(client, name, protocol, set);
+       conn->host = p_strdup(conn->pool, host);
+       conn->port = port;
+       conn->ssl_mode = ssl_mode;
+
+       return conn;
+}
+
 struct smtp_client_connection *
 smtp_client_connection_create_ip(struct smtp_client *client,
        enum smtp_protocol protocol, const struct ip_addr *ip, in_port_t port,