dovecot-2.1: snarf: Keep the mailbox locked during snarfing to a...

dovecot at dovecot.org dovecot at dovecot.org
Thu Feb 9 19:32:42 EET 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/28b73743c36f
changeset: 14103:28b73743c36f
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Feb 09 19:32:25 2012 +0200
description:
snarf: Keep the mailbox locked during snarfing to avoid duplicates.

diffstat:

 src/plugins/snarf/snarf-plugin.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (32 lines):

diff -r 665bb4bc72ca -r 28b73743c36f src/plugins/snarf/snarf-plugin.c
--- a/src/plugins/snarf/snarf-plugin.c	Thu Feb 09 16:27:54 2012 +0200
+++ b/src/plugins/snarf/snarf-plugin.c	Thu Feb 09 19:32:25 2012 +0200
@@ -38,7 +38,8 @@
 	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 @@
 	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 @@
 	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;


More information about the dovecot-cvs mailing list