dovecot-2.2: lib-storage: Avoid refreshing mailbox list index to...

dovecot at dovecot.org dovecot at dovecot.org
Mon May 26 01:06:53 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/60d2cfdc3140
changeset: 17388:60d2cfdc3140
user:      Timo Sirainen <tss at iki.fi>
date:      Mon May 26 04:05:34 2014 +0300
description:
lib-storage: Avoid refreshing mailbox list index too often.

diffstat:

 src/lib-storage/list/mailbox-list-index.c |  12 ++++++++++++
 src/lib-storage/list/mailbox-list-index.h |   1 +
 2 files changed, 13 insertions(+), 0 deletions(-)

diffs (41 lines):

diff -r e163a82b10f5 -r 60d2cfdc3140 src/lib-storage/list/mailbox-list-index.c
--- a/src/lib-storage/list/mailbox-list-index.c	Mon May 26 03:58:16 2014 +0300
+++ b/src/lib-storage/list/mailbox-list-index.c	Mon May 26 04:05:34 2014 +0300
@@ -366,7 +366,16 @@
 
 	if (ilist->syncing)
 		return 0;
+	if (ilist->last_refresh_timeval.tv_usec == ioloop_timeval.tv_usec &&
+	    ilist->last_refresh_timeval.tv_sec == ioloop_timeval.tv_sec) {
+		/* we haven't been to ioloop since last refresh, skip checking
+		   it. when we're accessing many mailboxes at once (e.g.
+		   opening a virtual mailbox) we don't want to stat/read the
+		   index every single time. */
+		return 0;
+	}
 
+	ilist->last_refresh_timeval = ioloop_timeval;
 	if (mailbox_list_index_index_open(list) < 0)
 		return -1;
 	if (mail_index_refresh(ilist->index) < 0) {
@@ -401,6 +410,9 @@
 	struct mail_index_view *view;
 	struct mail_index_transaction *trans;
 
+	memset(&ilist->last_refresh_timeval, 0,
+	       sizeof(ilist->last_refresh_timeval));
+
 	if (!ilist->has_backing_store)
 		return;
 
diff -r e163a82b10f5 -r 60d2cfdc3140 src/lib-storage/list/mailbox-list-index.h
--- a/src/lib-storage/list/mailbox-list-index.h	Mon May 26 03:58:16 2014 +0300
+++ b/src/lib-storage/list/mailbox-list-index.h	Mon May 26 04:05:34 2014 +0300
@@ -86,6 +86,7 @@
 	const char *path;
 	struct mail_index *index;
 	uint32_t ext_id, msgs_ext_id, hmodseq_ext_id, subs_hdr_ext_id;
+	struct timeval last_refresh_timeval;
 
 	pool_t mailbox_pool;
 	/* uin32_t id => name */


More information about the dovecot-cvs mailing list