From a2216a3dd83af5f6155efe1a93bdcea55a368e00 Mon Sep 17 00:00:00 2001 From: Stephan Bosch Date: Sat, 9 Feb 2019 12:44:04 +0100 Subject: [PATCH] lib-smtp: smtp-client-transaction - Explicitly keep track of whether a recipient is already finished. --- src/lib-smtp/smtp-client-private.h | 1 + src/lib-smtp/smtp-client-transaction.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/lib-smtp/smtp-client-private.h b/src/lib-smtp/smtp-client-private.h index 5ca2c20369..60b5a44618 100644 --- a/src/lib-smtp/smtp-client-private.h +++ b/src/lib-smtp/smtp-client-private.h @@ -92,6 +92,7 @@ struct smtp_client_transaction_rcpt { bool external_pool:1; bool queued:1; bool failed:1; + bool finished:1; }; struct smtp_client_transaction { diff --git a/src/lib-smtp/smtp-client-transaction.c b/src/lib-smtp/smtp-client-transaction.c index 9b9c35f5e7..26df4ecd5d 100644 --- a/src/lib-smtp/smtp-client-transaction.c +++ b/src/lib-smtp/smtp-client-transaction.c @@ -268,6 +268,10 @@ smtp_client_transaction_rcpt_replied( rcpt->rcpt_callback = NULL; rcpt->failed = !success; + if (rcpt->finished) + return; + rcpt->finished = rcpt->failed; + if (success) smtp_client_transaction_rcpt_approved(_rcpt); else @@ -301,6 +305,10 @@ smtp_client_transaction_rcpt_fail_reply( smtp_client_command_callback_t *callback; void *context; + if (rcpt->finished) + return; + rcpt->finished = TRUE; + if (rcpt->queued) { callback = rcpt->rcpt_callback; context = rcpt->context; @@ -323,6 +331,9 @@ static void smtp_client_transaction_rcpt_finished(struct smtp_client_transaction_rcpt *rcpt, const struct smtp_reply *reply) { + i_assert(!rcpt->finished); + rcpt->finished = TRUE; + if (rcpt->data_callback != NULL) rcpt->data_callback(reply, rcpt->data_context); rcpt->data_callback = NULL; @@ -333,6 +344,8 @@ void smtp_client_transaction_rcpt_set_data_callback( struct smtp_client_transaction_rcpt *rcpt, smtp_client_command_callback_t *callback, void *context) { + i_assert(!rcpt->finished); + rcpt->data_callback = callback; rcpt->data_context = context; } -- 2.47.3