From 84ebee89026c93430b4d91ad40eba2fe1f5be0fe Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 1 Feb 2022 14:40:48 +0100 Subject: [PATCH] lmtp: Simplify/clarify per-recipient session ID The session ID is the transaction ID followed by an increasing recipient count (number of RCPT commands) in the SMTP transaction. Clarify this by adding 'R' letter before the counter. Also don't add the counter suffix at all for the first recipient, since most transactions only have a single recipient. --- src/lmtp/lmtp-recipient.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lmtp/lmtp-recipient.c b/src/lmtp/lmtp-recipient.c index d92fe73540..aaad29b656 100644 --- a/src/lmtp/lmtp-recipient.c +++ b/src/lmtp/lmtp-recipient.c @@ -25,10 +25,12 @@ lmtp_recipient_create(struct client *client, /* Use a unique session_id for each mail delivery. This is especially important for stats process to not see duplicate sessions. */ - client->state.session_id_seq++; - lrcpt->session_id = p_strdup_printf(rcpt->pool, "%s:%u", trans->id, - client->state.session_id_seq); - + if (client->state.session_id_seq++ == 0) + lrcpt->session_id = trans->id; + else { + lrcpt->session_id = p_strdup_printf(rcpt->pool, "%s:R%u", + trans->id, client->state.session_id_seq); + } event_add_str(rcpt->event, "session", lrcpt->session_id); return lrcpt; -- 2.47.3