The connection event is only used as event parent when the MAIL command failed
in pipeline or when the recipient is destroyed prematurely. The log prefix of
the transaction event is dropped, so that the connection event log prefix is
used in either case. Therefore, the main visible effect of this commit is that
the transaction event fields are available in the recipient event when there is
a transaction, the log messages will not change.
if (rcpt->event != NULL)
return;
- rcpt->event = event_create(conn->event);
+ if (conn->state.trans == NULL) {
+ /* Use connection event directly if there is no transaction */
+ rcpt->event = event_create(conn->event);
+ } else {
+ /* Use transaction event, but drop its log prefix so that the
+ connection event prefix remains. */
+ rcpt->event = event_create(conn->state.trans->event);
+ event_drop_parent_log_prefixes(rcpt->event, 1);
+ }
smtp_server_recipient_update_event(prcpt);
}