]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: server: MAIL command: Improve replacement of (forwarded) specific error...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Fri, 28 Sep 2018 22:20:50 +0000 (00:20 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 10 Oct 2018 09:49:07 +0000 (09:49 +0000)
Predictable transaction state errors were not always replaced reliably when
commands were pipelined, leading to a mix of proxy and remote errors.

src/lib-smtp/smtp-server-cmd-mail.c

index 7b6cad0a554975f4deeaa7fe25764f34712e38f6..e9ee4b09dbbc986ad1d64758160b1f1b315e5cbc 100644 (file)
 
 /* MAIL command */
 
-static void
-cmd_mail_replied(struct smtp_server_cmd_ctx *cmd,
-                struct smtp_server_cmd_mail *data);
-
 static bool
 cmd_mail_check_state(struct smtp_server_cmd_ctx *cmd)
 {
@@ -38,8 +34,12 @@ cmd_mail_completed(struct smtp_server_cmd_ctx *cmd,
        conn->state.pending_mail_cmds--;
 
        i_assert(smtp_server_command_is_replied(command));
-       if (!smtp_server_command_replied_success(command))
+       if (!smtp_server_command_replied_success(command)) {
+               /* failure; substitute our own error if predictable */
+               if (smtp_server_command_reply_is_forwarded(command))
+                       (void)cmd_mail_check_state(cmd);
                return;
+       }
 
        /* success */
        conn->state.trans = smtp_server_transaction_create(conn,
@@ -52,20 +52,6 @@ cmd_mail_completed(struct smtp_server_cmd_ctx *cmd,
        }
 }
 
-static void
-cmd_mail_replied(struct smtp_server_cmd_ctx *cmd,
-                struct smtp_server_cmd_mail *data ATTR_UNUSED)
-{
-       struct smtp_server_command *command = cmd->cmd;
-
-       i_assert(smtp_server_command_is_replied(command));
-       if (!smtp_server_command_replied_success(command)) {
-               /* failure; substitute our own error if predictable */
-               (void)cmd_mail_check_state(cmd);
-               return;
-       }
-}
-
 static void
 cmd_mail_recheck(struct smtp_server_cmd_ctx *cmd,
                 struct smtp_server_cmd_mail *data ATTR_UNUSED)
@@ -181,8 +167,6 @@ void smtp_server_cmd_mail(struct smtp_server_cmd_ctx *cmd,
 
        smtp_server_command_add_hook(command, SMTP_SERVER_COMMAND_HOOK_NEXT,
                                     cmd_mail_recheck, mail_data);
-       smtp_server_command_add_hook(command, SMTP_SERVER_COMMAND_HOOK_REPLIED,
-                                    cmd_mail_replied, mail_data);
        smtp_server_command_add_hook(command, SMTP_SERVER_COMMAND_HOOK_COMPLETED,
                                     cmd_mail_completed, mail_data);