From: Timo Sirainen Date: Thu, 11 Aug 2011 15:02:25 +0000 (+0300) Subject: lib-storage: Added struct mailbox.generation_sequence. X-Git-Tag: 2.1.alpha1~125 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fcfe85637e1ee14a9fc39c41fd6ceca106301542;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Added struct mailbox.generation_sequence. This can be used for caching struct mailbox pointers and checking later if two struct mailboxes + their generation sequences match. If they do, it's the same struct mailbox. --- diff --git a/src/lib-storage/index/index-storage.c b/src/lib-storage/index/index-storage.c index eb8b25e446..6ac068bb4a 100644 --- a/src/lib-storage/index/index-storage.c +++ b/src/lib-storage/index/index-storage.c @@ -290,10 +290,12 @@ void index_storage_mailbox_alloc(struct mailbox *box, const char *vname, enum mailbox_flags flags, const char *index_prefix) { + static unsigned int mailbox_generation_sequence = 0; struct index_mailbox_context *ibox; i_assert(vname != NULL); + box->generation_sequence = ++mailbox_generation_sequence; box->vname = p_strdup(box->pool, vname); box->name = p_strdup(box->pool, mailbox_list_get_storage_name(box->list, vname)); diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index 66206dfe1b..c2648fe8fd 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -245,6 +245,9 @@ struct mailbox { mailbox_notify_callback_t *notify_callback; void *notify_context; + /* Increased by one for each new struct mailbox. */ + unsigned int generation_sequence; + /* Saved search results */ ARRAY_DEFINE(search_results, struct mail_search_result *);