From 0e0ce848d7261c7fc885472313b637af2eb57cf8 Mon Sep 17 00:00:00 2001 From: Stephan Bosch Date: Mon, 30 Oct 2017 20:50:28 +0100 Subject: [PATCH] lmtp: proxy: Merged lmtp_proxy_add_rcpt() into lmtp_proxy_rcpt(). --- src/lmtp/lmtp-proxy.c | 48 ++++++++++++++++++++----------------------- src/lmtp/lmtp-proxy.h | 6 ------ 2 files changed, 22 insertions(+), 32 deletions(-) diff --git a/src/lmtp/lmtp-proxy.c b/src/lmtp/lmtp-proxy.c index ef42bc6665..6106cbd177 100644 --- a/src/lmtp/lmtp-proxy.c +++ b/src/lmtp/lmtp-proxy.c @@ -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; } diff --git a/src/lmtp/lmtp-proxy.h b/src/lmtp/lmtp-proxy.h index 5e1e589753..dc69376c7e 100644 --- a/src/lmtp/lmtp-proxy.h +++ b/src/lmtp/lmtp-proxy.h @@ -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,