dovecot-2.1: lib-lda: Avoid doing a costly mailbox sync when del...

dovecot at dovecot.org dovecot at dovecot.org
Tue Oct 30 15:06:05 EET 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/9cdeab12f3e1
changeset: 14792:9cdeab12f3e1
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Oct 30 15:05:45 2012 +0200
description:
lib-lda: Avoid doing a costly mailbox sync when delivering mail to multiple recipients.

diffstat:

 src/lib-lda/mail-deliver.c         |   3 ++-
 src/lib-storage/index/index-sync.c |  11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletions(-)

diffs (34 lines):

diff -r 9d63f882194d -r 9cdeab12f3e1 src/lib-lda/mail-deliver.c
--- a/src/lib-lda/mail-deliver.c	Mon Oct 29 19:04:36 2012 +0200
+++ b/src/lib-lda/mail-deliver.c	Tue Oct 30 15:05:45 2012 +0200
@@ -331,7 +331,8 @@
 		ctx->saved_mail = TRUE;
 		mail_deliver_log(ctx, "saved mail to %s", mailbox_name);
 
-		if (ctx->save_dest_mail && mailbox_sync(box, 0) == 0) {
+		if (ctx->save_dest_mail &&
+		    mailbox_sync(box, MAILBOX_SYNC_FLAG_FAST) == 0) {
 			range = array_idx(&changes.saved_uids, 0);
 			i_assert(range[0].seq1 == range[0].seq2);
 
diff -r 9d63f882194d -r 9cdeab12f3e1 src/lib-storage/index/index-sync.c
--- a/src/lib-storage/index/index-sync.c	Mon Oct 29 19:04:36 2012 +0200
+++ b/src/lib-storage/index/index-sync.c	Tue Oct 30 15:05:45 2012 +0200
@@ -31,6 +31,17 @@
 	    ioloop_time < ibox->sync_last_check + MAILBOX_FULL_SYNC_INTERVAL)
 		return FALSE;
 
+	if ((flags & MAILBOX_SYNC_FLAG_FAST) != 0 &&
+	    (box->flags & MAILBOX_FLAG_SAVEONLY) != 0) {
+		/* lib-lda is syncing the mailbox after saving a mail.
+		   it only wants to find the new mail for potentially copying
+		   to other mailboxes. that's mainly an optimization, and since
+		   the mail was most likely already added to index we don't
+		   need to do a full sync to find it. the main benefit here is
+		   to avoid a very costly sync with a large Maildir/new/ */
+		return FALSE;
+	}
+
 	if (ibox->notify_to != NULL)
 		timeout_reset(ibox->notify_to);
 	ibox->sync_last_check = ioloop_time;


More information about the dovecot-cvs mailing list