]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-lda: Avoid doing a costly mailbox sync when delivering mail to multiple recipients.
authorTimo Sirainen <tss@iki.fi>
Tue, 30 Oct 2012 13:05:45 +0000 (15:05 +0200)
committerTimo Sirainen <tss@iki.fi>
Tue, 30 Oct 2012 13:05:45 +0000 (15:05 +0200)
src/lib-lda/mail-deliver.c
src/lib-storage/index/index-sync.c

index e15928dff15ed2fca5bc265d349517359ed0b283..615588c61b56d6cc5196f647b77fedcd03f714f5 100644 (file)
@@ -331,7 +331,8 @@ int mail_deliver_save(struct mail_deliver_context *ctx, const char *mailbox,
                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);
 
index c9398cb070c35a0f950916b5d4b9a68cd9c2d363..6cb70c06c4ae85a312e9014e60eaea8fda0aacec 100644 (file)
@@ -31,6 +31,17 @@ bool index_mailbox_want_full_sync(struct mailbox *box,
            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;