1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/* Copyright (c) 2018 Dovecot authors, see the included COPYING file */
#include "lmtp-common.h"
#include "array.h"
#include "smtp-server.h"
#include "lmtp-recipient.h"
struct lmtp_recipient_module_register
lmtp_recipient_module_register = { 0 };
struct lmtp_recipient *
lmtp_recipient_create(struct client *client,
struct smtp_server_transaction *trans,
struct smtp_server_recipient *rcpt)
{
struct lmtp_recipient *lrcpt;
lrcpt = p_new(rcpt->pool, struct lmtp_recipient, 1);
lrcpt->rcpt = rcpt;
lrcpt->client = client;
rcpt->context = lrcpt;
p_array_init(&lrcpt->module_contexts, rcpt->pool, 5);
/* Use a unique session_id for each mail delivery. This is especially
important for stats process to not see duplicate sessions. */
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;
}
struct lmtp_recipient *
lmtp_recipient_find_duplicate(struct lmtp_recipient *lrcpt,
struct smtp_server_transaction *trans)
{
struct smtp_server_recipient *drcpt;
struct lmtp_recipient *dup_lrcpt;
i_assert(lrcpt->rcpt != NULL);
drcpt = smtp_server_transaction_find_rcpt_duplicate(trans, lrcpt->rcpt);
if (drcpt == NULL)
return NULL;
dup_lrcpt = drcpt->context;
i_assert(dup_lrcpt->rcpt == drcpt);
i_assert(dup_lrcpt->type == lrcpt->type);
return dup_lrcpt;
}
|