]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lmtp: Simplify/clarify per-recipient session ID
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 1 Feb 2022 13:40:48 +0000 (14:40 +0100)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 1 Feb 2022 15:00:43 +0000 (16:00 +0100)
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

index d92fe735405136148e3a887abbd64acca34ac801..aaad29b65658de702e42acc54e3b7a1b2308ce91 100644 (file)
@@ -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;