]> 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 14:57:14 +0000 (15:57 +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 aec66334d51e3d17e1b63966778f744206285bc9..9f40c1f2185db881cf7cc8da0e92864e59e571ff 100644 (file)
@@ -51,10 +51,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;