dovecot-2.1: maildir: Avoid refreshing uidlist unnecessarily.
dovecot at dovecot.org
dovecot at dovecot.org
Mon Sep 5 12:47:10 EEST 2011
details: http://hg.dovecot.org/dovecot-2.1/rev/4124c28db2a4
changeset: 13401:4124c28db2a4
user: Timo Sirainen <tss at iki.fi>
date: Mon Sep 05 12:46:49 2011 +0300
description:
maildir: Avoid refreshing uidlist unnecessarily.
Even if the uidlist itself wasn't read, it was still stat()ed.
diffstat:
src/lib-storage/index/maildir/maildir-storage.h | 1 +
src/lib-storage/index/maildir/maildir-sync.c | 36 +++++++++++++-----------
2 files changed, 20 insertions(+), 17 deletions(-)
diffs (67 lines):
diff -r ae7a7282af83 -r 4124c28db2a4 src/lib-storage/index/maildir/maildir-storage.h
--- a/src/lib-storage/index/maildir/maildir-storage.h Mon Sep 05 11:48:11 2011 +0300
+++ b/src/lib-storage/index/maildir/maildir-storage.h Mon Sep 05 12:46:49 2011 +0300
@@ -93,6 +93,7 @@
unsigned int private_flags_mask_set:1;
unsigned int backend_readonly:1;
unsigned int backend_readonly_set:1;
+ unsigned int sync_uidlist_refreshed:1;
};
extern struct mail_vfuncs maildir_mail_vfuncs;
diff -r ae7a7282af83 -r 4124c28db2a4 src/lib-storage/index/maildir/maildir-sync.c
--- a/src/lib-storage/index/maildir/maildir-sync.c Mon Sep 05 11:48:11 2011 +0300
+++ b/src/lib-storage/index/maildir/maildir-sync.c Mon Sep 05 12:46:49 2011 +0300
@@ -942,26 +942,27 @@
int ret;
ret = maildir_uidlist_lookup(mbox->uidlist, uid, flags_r, fname_r);
- if (ret <= 0) {
- if (ret < 0)
+ if (ret != 0)
+ return ret;
+
+ if (maildir_uidlist_is_open(mbox->uidlist)) {
+ /* refresh uidlist and check again in case it was added
+ after the last mailbox sync */
+ if (mbox->sync_uidlist_refreshed) {
+ /* we've already refreshed it, don't bother again */
+ return ret;
+ }
+ mbox->sync_uidlist_refreshed = TRUE;
+ if (maildir_uidlist_refresh(mbox->uidlist) < 0)
return -1;
- if (maildir_uidlist_is_open(mbox->uidlist)) {
- /* refresh uidlist and check again in case it was added
- after the last mailbox sync */
- if (maildir_uidlist_refresh(mbox->uidlist) < 0)
- return -1;
- } else {
- /* the uidlist doesn't exist. */
- if (maildir_storage_sync_force(mbox, uid) < 0)
- return -1;
- }
-
- /* try again */
- ret = maildir_uidlist_lookup(mbox->uidlist, uid,
- flags_r, fname_r);
+ } else {
+ /* the uidlist doesn't exist. */
+ if (maildir_storage_sync_force(mbox, uid) < 0)
+ return -1;
}
- return ret;
+ /* try again */
+ return maildir_uidlist_lookup(mbox->uidlist, uid, flags_r, fname_r);
}
int maildir_storage_sync_force(struct maildir_mailbox *mbox, uint32_t uid)
@@ -1046,6 +1047,7 @@
maildir_uidlist_set_all_nonsynced(mbox->uidlist);
}
mbox->synced = TRUE;
+ mbox->sync_uidlist_refreshed = FALSE;
return index_mailbox_sync_init(box, flags, ret < 0);
}
More information about the dovecot-cvs
mailing list