]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Track storage's all mailboxes to make it easier to debug if one isn...
authorTimo Sirainen <tss@iki.fi>
Wed, 23 Nov 2011 17:19:19 +0000 (19:19 +0200)
committerTimo Sirainen <tss@iki.fi>
Wed, 23 Nov 2011 17:19:19 +0000 (19:19 +0200)
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c

index b1a44cb30083d13bb1fb527ca0e7d6ce0ed960e0..b13b76ea0a29f30a36a4a16a98757617daf5d251 100644 (file)
@@ -78,6 +78,8 @@ struct mail_storage {
        /* counting number of objects (e.g. mailbox) that have a pointer
           to this storage. */
        int obj_refcount;
+       /* Linked list of all mailboxes in the storage */
+       struct mailbox *mailboxes;
        const char *unique_root_dir;
 
        char *error_string;
@@ -210,6 +212,8 @@ struct mailbox {
         struct mailbox_vfuncs v, *vlast;
 /* private: */
        pool_t pool;
+       /* Linked list of all mailboxes in this storage */
+       struct mailbox *prev, *next;
 
        /* these won't be set until mailbox is opened: */
        struct mail_index *index;
index c84b94b58dbd5ae2f571fe2fcf51e23ff4331637..9cee661ccd12459d0a1424750361b7339041da15 100644 (file)
@@ -412,6 +412,10 @@ void mail_storage_unref(struct mail_storage **_storage)
                return;
        }
 
+       if (storage->mailboxes != NULL) {
+               i_panic("Trying to deinit storage without freeing mailbox %s",
+                       storage->mailboxes->vname);
+       }
        if (storage->obj_refcount != 0)
                i_panic("Trying to deinit storage before freeing its objects");
 
@@ -627,6 +631,7 @@ struct mailbox *mailbox_alloc(struct mailbox_list *list, const char *vname,
                hook_mailbox_allocated(box);
        } T_END;
 
+       DLLIST_PREPEND(&box->storage->mailboxes, box);
        mail_storage_obj_ref(box->storage);
        return box;
 }
@@ -893,6 +898,8 @@ void mailbox_free(struct mailbox **_box)
 
        mailbox_close(box);
        box->v.free(box);
+
+       DLLIST_REMOVE(&box->storage->mailboxes, box);
        mail_storage_obj_unref(box->storage);
        pool_unref(&box->pool);
 }