From: Stephan Bosch Date: Tue, 2 Oct 2018 19:44:48 +0000 (+0200) Subject: lib-smtp: client: transaction: Don't trigger next transaction unless all RCPT replies... X-Git-Tag: 2.3.9~1260 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=479f191070891f2555be5cd3f954b19c4e019623;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: client: transaction: Don't trigger next transaction unless all RCPT replies are received and DATA is submitted. Triggering the next transaction when DATA submitted while not all RCPT replies are received (as it was before) is problematic when commands are submitted immediately by the transaction (which is added in a later commit). --- diff --git a/src/lib-smtp/smtp-client-transaction.c b/src/lib-smtp/smtp-client-transaction.c index 421aa5f742..a9a3357128 100644 --- a/src/lib-smtp/smtp-client-transaction.c +++ b/src/lib-smtp/smtp-client-transaction.c @@ -585,10 +585,19 @@ smtp_client_transaction_rcpt_cb(const struct smtp_reply *reply, if (array_count(&trans->rcpts) == 0) { /* abort transaction if all recipients failed */ smtp_client_transaction_abort(trans); - } else if (conn->protocol == SMTP_PROTOCOL_LMTP && - trans->cmd_data != NULL) { - smtp_client_command_set_replies(trans->cmd_data, - array_count(&trans->rcpts)); + return; + } + + if (trans->cmd_data != NULL) { + if (conn->protocol == SMTP_PROTOCOL_LMTP) { + smtp_client_command_set_replies(trans->cmd_data, + array_count(&trans->rcpts)); + } + + /* Got replies for all recipients and submitted our last + command; the next transaction can submit its commands + now. */ + smtp_client_connection_next_transaction(trans->conn, trans); } } } @@ -753,17 +762,21 @@ smtp_client_transaction_send_data(struct smtp_client_transaction *trans) smtp_client_command_unlock(trans->cmd_last); if (array_count(&trans->rcpts_pending) == 0) { + smtp_client_transaction_debug(trans, "Got all RCPT replies"); + trans->state = SMTP_CLIENT_TRANSACTION_STATE_DATA; + if (conn->protocol == SMTP_PROTOCOL_LMTP) { smtp_client_command_set_replies( trans->cmd_data, array_count(&trans->rcpts)); } - } - /* Submitted our last command; the next transaction can submit - its commands now. */ - smtp_client_connection_next_transaction(trans->conn, trans); + /* Got replies for all recipients and submitted our last + command; the next transaction can submit its commands + now. */ + smtp_client_connection_next_transaction(trans->conn, trans); + } } if (trans->cmd_plug != NULL) @@ -783,9 +796,6 @@ void smtp_client_transaction_send( { i_assert(trans->state < SMTP_CLIENT_TRANSACTION_STATE_FINISHED); - if (array_count(&trans->rcpts_pending) == 0) - smtp_client_transaction_debug(trans, "Got all RCPT replies"); - smtp_client_transaction_debug(trans, "Send"); trans->data_provided = TRUE;