Skip to content

Commit

Permalink
lib-smtp: client: transaction: Don't trigger next transaction unless …
Browse files Browse the repository at this point in the history
…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).
  • Loading branch information
stephanbosch authored and cmouse committed Oct 10, 2018
1 parent cc9d4ca commit 479f191
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/lib-smtp/smtp-client-transaction.c
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down

0 comments on commit 479f191

Please sign in to comment.