]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lmtp: proxy: Merged lmtp_proxy_add_rcpt() into lmtp_proxy_rcpt().
authorStephan Bosch <stephan.bosch@dovecot.fi>
Mon, 30 Oct 2017 19:50:28 +0000 (20:50 +0100)
committerStephan Bosch <stephan.bosch@dovecot.fi>
Thu, 7 Dec 2017 23:10:07 +0000 (00:10 +0100)
src/lmtp/lmtp-proxy.c
src/lmtp/lmtp-proxy.h

index ef42bc666519c1e9cbf4b892685d6ef472c19497..6106cbd177a4e32873f7071b98bbdfb05cacdac4 100644 (file)
@@ -414,28 +414,6 @@ lmtp_proxy_rcpt_cb(const struct smtp_reply *proxy_reply,
        rcpt->rcpt_to_failed = !smtp_reply_is_success(proxy_reply);
 }
 
-int lmtp_proxy_add_rcpt(struct lmtp_proxy *proxy,
-                       const struct smtp_address *address,
-                       const struct lmtp_proxy_rcpt_settings *set)
-{
-       struct lmtp_proxy_connection *conn;
-       struct lmtp_proxy_recipient *rcpt;
-
-       conn = lmtp_proxy_get_connection(proxy, set);
-       if (conn->failed)
-               return -1;
-
-       rcpt = p_new(proxy->pool, struct lmtp_proxy_recipient, 1);
-       rcpt->idx = array_count(&proxy->rcpt_to);
-       rcpt->conn = conn;
-       rcpt->address = smtp_address_clone(proxy->pool, address);
-       array_append(&proxy->rcpt_to, &rcpt, 1);
-
-       smtp_client_transaction_add_rcpt(conn->lmtp_trans, address,
-               &set->params, lmtp_proxy_rcpt_cb, lmtp_proxy_data_cb, rcpt);
-       return 0;
-}
-
 int lmtp_proxy_rcpt(struct client *client,
                    struct smtp_address *address,
                    const char *username, const char *detail, char delim,
@@ -443,6 +421,8 @@ int lmtp_proxy_rcpt(struct client *client,
 {
        struct auth_master_connection *auth_conn;
        struct lmtp_proxy_rcpt_settings set;
+       struct lmtp_proxy_connection *conn;
+       struct lmtp_proxy_recipient *rcpt;
        struct auth_user_info info;
        struct mail_storage_service_input input;
        const char *const *fields, *errstr, *orig_username = username;
@@ -547,10 +527,26 @@ int lmtp_proxy_rcpt(struct client *client,
                lmtp_proxy_mail_from(client->proxy, client->state.mail_from,
                        &client->state.mail_params);
        }
-       if (lmtp_proxy_add_rcpt(client->proxy, address, &set) < 0)
-               client_send_line(client, "451 4.4.0 Remote server not answering");
-       else
-               client_send_line(client, "250 2.1.5 OK");
+
+       conn = lmtp_proxy_get_connection(client->proxy, &set);
+       if (conn->failed) {
+               client_send_line(client,
+                       "451 4.4.0 Remote server not answering");
+               pool_unref(&pool);
+               return -1;
+       }
+
+       rcpt = p_new(client->proxy->pool, struct lmtp_proxy_recipient, 1);
+       rcpt->idx = array_count(&client->proxy->rcpt_to);
+       rcpt->conn = conn;
+       rcpt->address = smtp_address_clone(client->proxy->pool, address);
+       array_append(&client->proxy->rcpt_to, &rcpt, 1);
+
+       smtp_client_transaction_add_rcpt(conn->lmtp_trans,
+               address, &set.params,
+               lmtp_proxy_rcpt_cb, lmtp_proxy_data_cb, rcpt);
+
+       client_send_line(client, "250 2.1.5 OK");
        pool_unref(&pool);
        return 1;
 }
index 5e1e589753f7b50b3c3aadf6c994c26623ee92ce..dc69376c7ebc6124a97158def663e8db1ec6b3cf 100644 (file)
@@ -37,12 +37,6 @@ void lmtp_proxy_deinit(struct lmtp_proxy **proxy);
 
 unsigned int lmtp_proxy_rcpt_count(struct client *client);
 
-/* Add a new recipient. Returns -1 if we already know that the destination
-   host can't be reached. */
-int lmtp_proxy_add_rcpt(struct lmtp_proxy *proxy,
-                       const struct smtp_address *address,
-                       const struct lmtp_proxy_rcpt_settings *set);
-
 int lmtp_proxy_rcpt(struct client *client,
                    struct smtp_address *address,
                    const char *username, const char *detail, char delim,