]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: client: transaction: Don't trigger next transaction unless all RCPT replies...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Tue, 2 Oct 2018 19:44:48 +0000 (21:44 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 12 Feb 2019 13:40:48 +0000 (15:40 +0200)
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).

src/lib-smtp/smtp-client-transaction.c

index 421aa5f74290506995b16c22707480f89faf3694..a9a335712826fdcf432825a4af27389ae8fa75b5 100644 (file)
@@ -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;