]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Added struct mailbox.generation_sequence.
authorTimo Sirainen <tss@iki.fi>
Thu, 11 Aug 2011 15:02:25 +0000 (18:02 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 11 Aug 2011 15:02:25 +0000 (18:02 +0300)
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.

src/lib-storage/index/index-storage.c
src/lib-storage/mail-storage-private.h

index eb8b25e446aae0576c6723bed727f660f79cd1ea..6ac068bb4a0f5b8d1c6f86d8e040a95d420a2781 100644 (file)
@@ -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));
index 66206dfe1b318d8f169332a8c7338312a83e0430..c2648fe8fdc4008f2b31b304cc0ef05ebe3066ba 100644 (file)
@@ -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 *);