Skip to content

Commit

Permalink
lib-smtp: client: Move connection to TRANSACTION state immediately wh…
Browse files Browse the repository at this point in the history
…en a transaction is started.

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)
  • Loading branch information
stephanbosch authored and mrannanj committed Feb 18, 2019
1 parent cd7ea3c commit 511f513
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib-smtp/smtp-client-connection.c
Expand Up @@ -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");
Expand All @@ -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);
}
Expand Down

0 comments on commit 511f513

Please sign in to comment.