]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: client: Move connection to TRANSACTION state immediately when a transaction...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Thu, 27 Dec 2018 13:13:15 +0000 (14:13 +0100)
committerStephan Bosch <stephan.bosch@dovecot.fi>
Thu, 27 Dec 2018 13:13:15 +0000 (14:13 +0100)
Before, it waited until the actual start handler was called from timeout, but
that causes a race condition with mtp_client_connection_abort_transaction(),
which in turn causes an assert panic.

Panic was:

Panic: file smtp-client-connection.c: line 2153 (smtp_client_connection_abort_transaction): assertion failed: (conn->state != SMTP_CLIENT_CONNECTION_STATE_READY)

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

index 55d26d14765810a5acd032c33b21e59617be6faa..ed3889649ffb09c13e1afb12b6e0b564fabfaaf1 100644 (file)
@@ -2097,14 +2097,12 @@ smtp_client_connection_do_start_transaction(struct smtp_client_connection *conn)
 
        if (conn->transactions_head == NULL)
                return;
-       if (conn->state != SMTP_CLIENT_CONNECTION_STATE_READY)
+       if (conn->state != SMTP_CLIENT_CONNECTION_STATE_TRANSACTION)
                return;
 
        if (conn->reset_needed)
                smtp_client_connection_reset(conn);
 
-       smtp_client_connection_set_state(conn,
-               SMTP_CLIENT_CONNECTION_STATE_TRANSACTION);
        smtp_client_connection_debug(conn, "Start next transaction");
 
        smtp_reply_init(&reply, 200, "Connection ready");
@@ -2120,6 +2118,8 @@ smtp_client_connection_start_transaction(struct smtp_client_connection *conn)
        if (conn->to_trans != NULL)
                return;
 
+       smtp_client_connection_set_state(conn,
+               SMTP_CLIENT_CONNECTION_STATE_TRANSACTION);
        conn->to_trans = timeout_add_short(0,
                smtp_client_connection_do_start_transaction, conn);
 }