From: Timo Sirainen Date: Wed, 23 Nov 2011 17:19:19 +0000 (+0200) Subject: lib-storage: Track storage's all mailboxes to make it easier to debug if one isn... X-Git-Tag: 2.1.rc1~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eecb235c14b49c01774134ea593c266f2d2c2be1;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Track storage's all mailboxes to make it easier to debug if one isn't closed. --- diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index b1a44cb300..b13b76ea0a 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -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; diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index c84b94b58d..9cee661ccd 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -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); }