]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: smtp-client-command - Make sure command event is finished just once.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 2 Mar 2019 12:08:34 +0000 (13:08 +0100)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Fri, 28 Jun 2019 07:09:52 +0000 (10:09 +0300)
src/lib-smtp/smtp-client-command.c
src/lib-smtp/smtp-client-private.h

index 7803ab5726a096efff55b826d7af0ae8dcc9f986..f39971f4f2721c93284a32942445e451b0d9e599 100644 (file)
@@ -188,7 +188,8 @@ void smtp_client_command_abort(struct smtp_client_command **_cmd)
                state >= SMTP_CLIENT_COMMAND_STATE_FINISHED)
                return;
 
-       if (!cmd->failed) {
+       struct event_passthrough *e = event_create_passthrough(cmd->event);
+       if (!cmd->event_finished) {
                struct smtp_reply failure;
 
                smtp_reply_init(&failure,
@@ -196,17 +197,12 @@ void smtp_client_command_abort(struct smtp_client_command **_cmd)
                                "Aborted");
                failure.enhanced_code = SMTP_REPLY_ENH_CODE(9, 0, 0);
 
-               struct event_passthrough *e =
-                       event_create_passthrough(cmd->event)->
-                       set_name("smtp_client_command_finished");
+               e->set_name("smtp_client_command_finished");
                smtp_reply_add_to_event(&failure, e);
-
-               e_debug(e->event(), "Aborted%s",
-                       (was_sent ? " (already sent)" : ""));
-       } else {
-               e_debug(cmd->event, "Aborted%s",
-                       (was_sent ? " (already sent)" : ""));
+               cmd->event_finished = TRUE;
        }
+       e_debug(e->event(), "Aborted%s",
+               (was_sent ? " (already sent)" : ""));
 
        if (!was_sent) {
                cmd->state = SMTP_CLIENT_COMMAND_STATE_ABORTED;
@@ -316,9 +312,12 @@ void smtp_client_command_fail_reply(struct smtp_client_command **_cmd,
                cmd->failed = TRUE;
 
                struct event_passthrough *e =
-                       event_create_passthrough(cmd->event)->
-                       set_name("smtp_client_command_finished");
-               smtp_reply_add_to_event(reply, e);
+                       event_create_passthrough(cmd->event);
+               if (!cmd->event_finished) {
+                       e->set_name("smtp_client_command_finished");
+                       smtp_reply_add_to_event(reply, e);
+                       cmd->event_finished = TRUE;
+               }
                e_debug(e->event(), "Failed: %s", smtp_reply_log(reply));
 
                if (callback != NULL)
index caf4ddbaf177c28b062421aa3ee3b0de00ff8385..201350860eb8b738f240a82c10cb446c48ec6ce5 100644 (file)
@@ -55,6 +55,7 @@ struct smtp_client_command {
        bool aborting:1;
        bool delay_failure:1;
        bool delaying_failure:1;
+       bool event_finished:1;
 };
 
 struct smtp_client_transaction_mail {