dovecot-2.2: mail-index: call all expunge handlers first

dovecot at dovecot.org dovecot at dovecot.org
Mon Jun 2 11:53:49 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/aa6e69727edb
changeset: 17421:aa6e69727edb
user:      Phil Carmody <phil at dovecot.fi>
date:      Mon Jun 02 14:50:34 2014 +0300
description:
mail-index: call all expunge handlers first
Firstly, the init checking only needs to be done once. More importantly,
moving this preparatory stage into its own per-seqs loop means there's
less to juggle when we optimise the memmoving loop in subequent patches.

Based on draft patch by Timo Sirainen.

Signed-off-by: Phil Carmody <phil at dovecot.fi>

diffstat:

 src/lib-index/mail-index-sync-update.c |  14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diffs (32 lines):

diff -r 211c9493aaa4 -r aa6e69727edb src/lib-index/mail-index-sync-update.c
--- a/src/lib-index/mail-index-sync-update.c	Mon Jun 02 14:50:34 2014 +0300
+++ b/src/lib-index/mail-index-sync-update.c	Mon Jun 02 14:50:34 2014 +0300
@@ -242,9 +242,6 @@
 	struct mail_index_record *rec;
 	uint32_t seq_count, seq;
 
-	if (sync_expunge_handlers_init(ctx))
-		sync_expunge_call_handlers(ctx, seq1, seq2);
-
 	map = mail_index_sync_get_atomic_map(ctx);
 	for (seq = seq1; seq <= seq2; seq++) {
 		rec = MAIL_INDEX_MAP_IDX(map, seq-1);
@@ -268,8 +265,17 @@
 	const struct seq_range *range;
 	unsigned int i, count;
 
+	/* call the expunge handlers first */
+	range = array_get(seqs, &count);
+	i_assert(count > 0);
+	if (sync_expunge_handlers_init(ctx)) {
+		for (i = 0; i < count; i++) {
+			sync_expunge_call_handlers(ctx,
+				range[i].seq1, range[i].seq2);
+		}
+	}
+
 	/* do this in reverse so the memmove()s are smaller */
-	range = array_get(seqs, &count);
 	for (i = count; i > 0; i--)
 		sync_expunge(ctx, range[i-1].seq1, range[i-1].seq2);
 }


More information about the dovecot-cvs mailing list