From: Stephan Bosch Date: Fri, 28 Sep 2018 22:20:50 +0000 (+0200) Subject: lib-smtp: server: MAIL command: Improve replacement of (forwarded) specific error... X-Git-Tag: 2.3.9~1267 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6406c30c908ab84d4a928f3680fba976b2d04bcc;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: server: MAIL command: Improve replacement of (forwarded) specific error reply with generic state error. Predictable transaction state errors were not always replaced reliably when commands were pipelined, leading to a mix of proxy and remote errors. --- diff --git a/src/lib-smtp/smtp-server-cmd-mail.c b/src/lib-smtp/smtp-server-cmd-mail.c index 7b6cad0a55..e9ee4b09db 100644 --- a/src/lib-smtp/smtp-server-cmd-mail.c +++ b/src/lib-smtp/smtp-server-cmd-mail.c @@ -11,10 +11,6 @@ /* 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);