dovecot-2.0: lib-lda: Do INBOX GUID deduplication based on mailb...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Jul 12 09:59:49 EEST 2011
details: http://hg.dovecot.org/dovecot-2.0/rev/e6300c6a5814
changeset: 12868:e6300c6a5814
user: Timo Sirainen <tss at iki.fi>
date: Tue Jul 12 09:59:34 2011 +0300
description:
lib-lda: Do INBOX GUID deduplication based on mailbox GUID, not username.
This should be a bit more reliable.
diffstat:
src/lib-lda/mail-deliver.c | 25 ++++++++++++++-----------
src/lib-lda/mail-deliver.h | 6 ++++--
2 files changed, 18 insertions(+), 13 deletions(-)
diffs (78 lines):
diff -r aaffc1bf6c65 -r e6300c6a5814 src/lib-lda/mail-deliver.c
--- a/src/lib-lda/mail-deliver.c Tue Jul 12 09:58:29 2011 +0300
+++ b/src/lib-lda/mail-deliver.c Tue Jul 12 09:59:34 2011 +0300
@@ -214,20 +214,25 @@
}
static bool mail_deliver_check_duplicate(struct mail_deliver_session *session,
- struct mail_user *user)
+ struct mailbox *box)
{
- const char *const *usernamep, *username;
+ uint8_t box_guid[MAIL_GUID_128_SIZE];
+ const mail_guid_128_t *guid;
+
+ if (mailbox_get_guid(box, box_guid) < 0) {
+ /* just play it safe and assume a duplicate */
+ return TRUE;
+ }
/* there shouldn't be all that many recipients,
so just do a linear search */
- if (!array_is_created(&session->inbox_users))
- p_array_init(&session->inbox_users, session->pool, 8);
- array_foreach(&session->inbox_users, usernamep) {
- if (strcmp(*usernamep, user->username) == 0)
+ if (!array_is_created(&session->inbox_guids))
+ p_array_init(&session->inbox_guids, session->pool, 8);
+ array_foreach(&session->inbox_guids, guid) {
+ if (memcmp(box_guid, guid, sizeof(box_guid)) == 0)
return TRUE;
}
- username = p_strdup(session->pool, user->username);
- array_append(&session->inbox_users, &username, 1);
+ array_append(&session->inbox_guids, &box_guid, 1);
return FALSE;
}
@@ -237,8 +242,6 @@
struct mailbox_transaction_context *trans =
mailbox_save_get_transaction(save_ctx);
struct mailbox *box = mailbox_transaction_get_mailbox(trans);
- struct mail_storage *storage = mailbox_get_storage(box);
- struct mail_user *user = mail_storage_get_user(storage);
uint8_t guid[MAIL_GUID_128_SIZE];
if (strcmp(mailbox_get_name(box), "INBOX") != 0)
@@ -248,7 +251,7 @@
happens if mail is delivered to same user multiple times within a
session. the problem with this is that if GUIDs are used as POP3
UIDLs, some clients can't handle the duplicates well. */
- if (mail_deliver_check_duplicate(session, user)) {
+ if (mail_deliver_check_duplicate(session, box)) {
mail_generate_guid_128(guid);
mailbox_save_set_guid(save_ctx, mail_guid_128_to_string(guid));
}
diff -r aaffc1bf6c65 -r e6300c6a5814 src/lib-lda/mail-deliver.h
--- a/src/lib-lda/mail-deliver.h Tue Jul 12 09:58:29 2011 +0300
+++ b/src/lib-lda/mail-deliver.h Tue Jul 12 09:59:34 2011 +0300
@@ -1,6 +1,8 @@
#ifndef MAIL_DELIVER_H
#define MAIL_DELIVER_H
+#include "mail-types.h"
+
enum mail_flags;
enum mail_error;
struct mail_storage;
@@ -10,8 +12,8 @@
struct mail_deliver_session {
pool_t pool;
- /* List of users who have already saved this mail to their INBOX */
- ARRAY_TYPE(const_string) inbox_users;
+ /* List of INBOX GUIDs where this mail has already been saved to */
+ ARRAY_DEFINE(inbox_guids, mail_guid_128_t);
};
struct mail_deliver_context {
More information about the dovecot-cvs
mailing list