From: Timo Sirainen Date: Thu, 9 Feb 2012 17:32:25 +0000 (+0200) Subject: snarf: Keep the mailbox locked during snarfing to avoid duplicates. X-Git-Tag: 2.1.rc6~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4abfd8fcb814730b17cede56d8bd10fa7529361f;p=thirdparty%2Fdovecot%2Fcore.git snarf: Keep the mailbox locked during snarfing to avoid duplicates. --- diff --git a/src/plugins/snarf/snarf-plugin.c b/src/plugins/snarf/snarf-plugin.c index ee5eef771b..7b8bda3476 100644 --- a/src/plugins/snarf/snarf-plugin.c +++ b/src/plugins/snarf/snarf-plugin.c @@ -38,7 +38,8 @@ static int snarf(struct mailbox *srcbox, struct mailbox *destbox) enum mail_error error; int ret; - /* make sure the destination mailbox has been opened */ + /* make sure the destination mailbox has been opened. + note that this locks the mailbox. */ if (mailbox_open(destbox) < 0) return -1; @@ -103,6 +104,8 @@ snarf_sync_init(struct mailbox *box, enum mailbox_sync_flags flags) struct snarf_mailbox *sbox = SNARF_CONTEXT(box); (void)snarf(sbox->snarf_box, box); + /* close the mailbox so that we don't have to keep it locked */ + (void)mailbox_close(sbox->snarf_box); return sbox->module_ctx.super.sync_init(box, flags); } @@ -160,7 +163,8 @@ static void snarf_mailbox_allocated(struct mailbox *box) sbox->module_ctx.super = *v; box->vlast = &sbox->module_ctx.super; - sbox->snarf_box = mailbox_alloc(snarf_list, snarf_name, 0); + sbox->snarf_box = mailbox_alloc(snarf_list, snarf_name, + MAILBOX_FLAG_KEEP_LOCKED); v->sync_init = snarf_sync_init; v->free = snarf_mailbox_free;