dovecot-2.2: lib-storage: Optimize mailbox_exists() with mailbox...
dovecot at dovecot.org
dovecot at dovecot.org
Mon May 26 00:59:23 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/e163a82b10f5
changeset: 17387:e163a82b10f5
user: Timo Sirainen <tss at iki.fi>
date: Mon May 26 03:58:16 2014 +0300
description:
lib-storage: Optimize mailbox_exists() with mailbox_list_index=yes
We can return the existence from the index itself to avoid stat()s.
diffstat:
src/lib-storage/list/mailbox-list-index-status.c | 31 ++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diffs (48 lines):
diff -r a9966b4aa020 -r e163a82b10f5 src/lib-storage/list/mailbox-list-index-status.c
--- a/src/lib-storage/list/mailbox-list-index-status.c Wed May 21 18:12:05 2014 -0700
+++ b/src/lib-storage/list/mailbox-list-index-status.c Mon May 26 03:58:16 2014 +0300
@@ -66,6 +66,36 @@
return 1;
}
+static int
+index_list_exists(struct mailbox *box, bool auto_boxes,
+ enum mailbox_existence *existence_r)
+{
+ struct index_list_mailbox *ibox = INDEX_LIST_STORAGE_CONTEXT(box);
+ struct mail_index_view *view;
+ const struct mail_index_record *rec;
+ enum mailbox_list_index_flags flags;
+ uint32_t seq;
+ int ret;
+
+ if ((ret = index_list_open_view(box, &view, &seq)) <= 0) {
+ /* failure / not found. fallback to the real storage check
+ just in case to see if the mailbox was just created. */
+ return ibox->module_ctx.super.
+ exists(box, auto_boxes, existence_r);
+ }
+ rec = mail_index_lookup(view, seq);
+ flags = rec->flags;
+ mail_index_view_close(&view);
+
+ if ((flags & MAILBOX_LIST_INDEX_FLAG_NONEXISTENT) != 0)
+ *existence_r = MAILBOX_EXISTENCE_NONE;
+ else if ((flags & MAILBOX_LIST_INDEX_FLAG_NOSELECT) != 0)
+ *existence_r = MAILBOX_EXISTENCE_NOSELECT;
+ else
+ *existence_r = MAILBOX_EXISTENCE_SELECT;
+ return 0;
+}
+
bool mailbox_list_index_status(struct mailbox_list *list,
struct mail_index_view *view,
uint32_t seq, enum mailbox_status_items items,
@@ -532,6 +562,7 @@
void mailbox_list_index_status_init_mailbox(struct mailbox *box)
{
+ box->v.exists = index_list_exists;
box->v.get_status = index_list_get_status;
box->v.get_metadata = index_list_get_metadata;
box->v.sync_deinit = index_list_sync_deinit;
More information about the dovecot-cvs
mailing list