]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: smtp-client-command - Create local variable for "was_sent" command status.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Mon, 4 Feb 2019 00:31:40 +0000 (01:31 +0100)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Fri, 28 Jun 2019 07:09:26 +0000 (10:09 +0300)
The condition is amended with (state < SMTP_CLIENT_COMMAND_STATE_FINISHED),
because that part is now checked after the intiialization of this variable
(causing the function to exit). It is important that the content of this
variable makes sense immediately (for future changes), rather than only after
the if statement that checks the added condition.

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

index 0b5076a526538e68216aaa75af0eb6b7f0f885ec..a7eec4c1f7a0b8bf25d4da770836706b71d0ae9f 100644 (file)
@@ -177,6 +177,9 @@ void smtp_client_command_abort(struct smtp_client_command **_cmd)
        bool was_locked =
                (state >= SMTP_CLIENT_COMMAND_STATE_SUBMITTED) &&
                (cmd->locked || cmd->plug);
+       bool was_sent =
+               (!disconnected && state > SMTP_CLIENT_COMMAND_STATE_SUBMITTED &&
+                state < SMTP_CLIENT_COMMAND_STATE_FINISHED);
 
        *_cmd = NULL;
 
@@ -186,7 +189,7 @@ void smtp_client_command_abort(struct smtp_client_command **_cmd)
                state >= SMTP_CLIENT_COMMAND_STATE_FINISHED)
                return;
 
-       if (disconnected || state <= SMTP_CLIENT_COMMAND_STATE_SUBMITTED) {
+       if (!was_sent) {
                e_debug(cmd->event, "Abort");
                cmd->state = SMTP_CLIENT_COMMAND_STATE_ABORTED;
        } else {