dovecot-2.2: lib-storage: Further changes to mailbox_alloc_guid(...

dovecot at dovecot.org dovecot at dovecot.org
Tue Apr 15 22:04:52 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/c2755572d31e
changeset: 17223:c2755572d31e
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Apr 16 00:04:29 2014 +0200
description:
lib-storage: Further changes to mailbox_alloc_guid() caching.
We'll now cache the GUIDs forever and force invalidation after mailbox
rename or when mailbox GUIDs have been updated. This is what dsync needs,
especially for good performance, and currently there aren't any other users
for this API.

diffstat:

 src/lib-storage/mail-storage.c         |   2 +-
 src/lib-storage/mailbox-guid-cache.c   |  13 ++++---------
 src/lib-storage/mailbox-list-private.h |   2 +-
 3 files changed, 6 insertions(+), 11 deletions(-)

diffs (72 lines):

diff -r 26b468dc7f11 -r c2755572d31e src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c	Tue Apr 15 23:44:54 2014 +0200
+++ b/src/lib-storage/mail-storage.c	Wed Apr 16 00:04:29 2014 +0200
@@ -1240,7 +1240,7 @@
 	ret = box->v.create_box(box, update, directory);
 	box->creating = FALSE;
 	if (ret == 0)
-		box->list->guid_cache_invalidated = TRUE;
+		box->list->guid_cache_updated = TRUE;
 	return ret;
 }
 
diff -r 26b468dc7f11 -r c2755572d31e src/lib-storage/mailbox-guid-cache.c
--- a/src/lib-storage/mailbox-guid-cache.c	Tue Apr 15 23:44:54 2014 +0200
+++ b/src/lib-storage/mailbox-guid-cache.c	Wed Apr 16 00:04:29 2014 +0200
@@ -12,24 +12,19 @@
 	const char *vname;
 };
 
-static bool mailbox_guid_cache_want_refresh(struct mailbox_list *list)
-{
-	return list->guid_cache_invalidated ||
-		list->guid_cache_last_update < ioloop_time;
-}
-
 int mailbox_guid_cache_find(struct mailbox_list *list,
 			    const guid_128_t guid, const char **vname_r)
 {
 	const struct mailbox_guid_cache_rec *rec;
 	const uint8_t *guid_p = guid;
 
-	if (!hash_table_is_created(list->guid_cache)) {
+	if (!hash_table_is_created(list->guid_cache) ||
+	    list->guid_cache_invalidated) {
 		mailbox_guid_cache_refresh(list);
 		rec = hash_table_lookup(list->guid_cache, guid_p);
 	} else {
 		rec = hash_table_lookup(list->guid_cache, guid_p);
-		if (rec == NULL && mailbox_guid_cache_want_refresh(list)) {
+		if (rec == NULL && list->guid_cache_updated) {
 			mailbox_guid_cache_refresh(list);
 			rec = hash_table_lookup(list->guid_cache, guid_p);
 		}
@@ -60,8 +55,8 @@
 		hash_table_clear(list->guid_cache, TRUE);
 		p_clear(list->guid_cache_pool);
 	}
-	list->guid_cache_last_update = ioloop_time;
 	list->guid_cache_invalidated = FALSE;
+	list->guid_cache_updated = FALSE;
 	list->guid_cache_errors = FALSE;
 
 	ctx = mailbox_list_iter_init(list, "*",
diff -r 26b468dc7f11 -r c2755572d31e src/lib-storage/mailbox-list-private.h
--- a/src/lib-storage/mailbox-list-private.h	Tue Apr 15 23:44:54 2014 +0200
+++ b/src/lib-storage/mailbox-list-private.h	Wed Apr 16 00:04:29 2014 +0200
@@ -122,7 +122,6 @@
 	struct mailbox_log *changelog;
 	time_t changelog_timestamp;
 
-	time_t guid_cache_last_update;
 	pool_t guid_cache_pool;
 	HASH_TABLE(uint8_t *, struct mailbox_guid_cache_rec *) guid_cache;
 	bool guid_cache_errors;
@@ -134,6 +133,7 @@
 	ARRAY(union mailbox_list_module_context *) module_contexts;
 
 	unsigned int index_root_dir_created:1;
+	unsigned int guid_cache_updated:1;
 	unsigned int guid_cache_invalidated:1;
 };
 


More information about the dovecot-cvs mailing list