Skip to content

Commit

Permalink
lib-smtp: smtp-client-command - Make sure command event is finished j…
Browse files Browse the repository at this point in the history
…ust once.
  • Loading branch information
stephanbosch authored and sirainen committed Mar 5, 2019
1 parent 622d67f commit 0343a55
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/lib-smtp/smtp-client-command.c
Expand Up @@ -188,25 +188,21 @@ 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,
SMTP_CLIENT_COMMAND_ERROR_ABORTED,
"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;
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/lib-smtp/smtp-client-private.h
Expand Up @@ -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 {
Expand Down

0 comments on commit 0343a55

Please sign in to comment.