]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Added mailbox.free() method. Use it instead of close() where necessary.
authorTimo Sirainen <tss@iki.fi>
Mon, 15 Feb 2010 00:54:32 +0000 (02:54 +0200)
committerTimo Sirainen <tss@iki.fi>
Mon, 15 Feb 2010 00:54:32 +0000 (02:54 +0200)
--HG--
branch : HEAD

16 files changed:
src/lib-storage/index/cydir/cydir-storage.c
src/lib-storage/index/dbox-multi/mdbox-storage.c
src/lib-storage/index/dbox-single/sdbox-storage.c
src/lib-storage/index/index-storage.c
src/lib-storage/index/index-thread-private.h
src/lib-storage/index/index-thread.c
src/lib-storage/index/maildir/maildir-storage.c
src/lib-storage/index/mbox/mbox-storage.c
src/lib-storage/index/raw/raw-storage.c
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c
src/lib-storage/test-mailbox.c
src/plugins/acl/acl-mailbox.c
src/plugins/fts/fts-storage.c
src/plugins/quota/quota-storage.c
src/plugins/virtual/virtual-storage.c

index 367f41684eef67116a96c57b21a5d6c993d54be7..6912de72840f48a9a50e4cd83fcf8d8a1d5e8d31 100644 (file)
@@ -140,6 +140,7 @@ struct mailbox cydir_mailbox = {
                index_storage_mailbox_enable,
                cydir_mailbox_open,
                index_storage_mailbox_close,
+               NULL,
                cydir_mailbox_create,
                index_storage_mailbox_update,
                index_storage_mailbox_delete,
index 8a13635635fcb142021f2f74e87ade5dabcb1d2c..ed6692106bf1ed62b0d25f189babc00cbf49f856 100644 (file)
@@ -327,6 +327,7 @@ struct mailbox mdbox_mailbox = {
                index_storage_mailbox_enable,
                dbox_mailbox_open,
                index_storage_mailbox_close,
+               NULL,
                dbox_mailbox_create,
                mdbox_mailbox_update,
                mdbox_mailbox_delete,
index 4ea1a896b716606a1a37d4c51202931a40e04d9b..217f22cde8593b2303f1c7333091ce6c520bbeee 100644 (file)
@@ -217,6 +217,7 @@ struct mailbox sdbox_mailbox = {
                index_storage_mailbox_enable,
                dbox_mailbox_open,
                index_storage_mailbox_close,
+               NULL,
                dbox_mailbox_create,
                dbox_mailbox_update,
                index_storage_mailbox_delete,
index 29a3edc4dd51eb8e658d6aaa47de45ce56734d79..a83da96540ba2fa72e5675848739a6716a45ef13 100644 (file)
@@ -243,7 +243,6 @@ int index_storage_mailbox_open(struct mailbox *box, bool move_to_memory)
 
        box->opened = TRUE;
 
-       index_thread_mailbox_opened(box);
        if (hook_mailbox_opened != NULL)
                hook_mailbox_opened(box);
 
@@ -291,6 +290,8 @@ void index_storage_mailbox_alloc(struct mailbox *box, const char *name,
        mail_index_set_permissions(box->index, box->file_create_mode,
                                   box->file_create_gid,
                                   box->file_create_gid_origin);
+
+       index_thread_mailbox_allocated(box);
 }
 
 int index_storage_mailbox_enable(struct mailbox *box,
index 4f44319188c353512ac7ea27f798703d33848ed7..5b33ad36fa201a2aa7d99a983af4e6640a814711 100644 (file)
@@ -77,6 +77,6 @@ mail_thread_iterate_init_full(struct mail_thread_cache *cache,
                              enum mail_thread_type thread_type,
                              bool return_seqs);
 
-void index_thread_mailbox_opened(struct mailbox *box);
+void index_thread_mailbox_allocated(struct mailbox *box);
 
 #endif
index 991421cffa071e1b8cf1a671917c1b34959b0005..9df859869642038a4974cb53baa1bbeb926023ce 100644 (file)
@@ -622,23 +622,31 @@ static void mail_thread_mailbox_close(struct mailbox *box)
 
        if (tbox->strmap_view != NULL)
                mail_index_strmap_view_close(&tbox->strmap_view);
-       mail_index_strmap_deinit(&tbox->strmap);
        if (tbox->cache->search_result != NULL)
                mailbox_search_result_free(&tbox->cache->search_result);
+       tbox->module_ctx.super.close(box);
+}
+
+static void mail_thread_mailbox_free(struct mailbox *box)
+{
+       struct mail_thread_mailbox *tbox = MAIL_THREAD_CONTEXT(box);
+
+       mail_index_strmap_deinit(&tbox->strmap);
+       tbox->module_ctx.super.free(box);
+
        array_free(&tbox->cache->thread_nodes);
        i_free(tbox->cache);
-
-       tbox->module_ctx.super.close(box);
        i_free(tbox);
 }
 
-void index_thread_mailbox_opened(struct mailbox *box)
+void index_thread_mailbox_allocated(struct mailbox *box)
 {
        struct mail_thread_mailbox *tbox;
 
        tbox = i_new(struct mail_thread_mailbox, 1);
        tbox->module_ctx.super = box->v;
        box->v.close = mail_thread_mailbox_close;
+       box->v.free = mail_thread_mailbox_free;
 
        tbox->strmap = mail_index_strmap_init(box->index,
                                              MAIL_THREAD_INDEX_SUFFIX);
index cfa9d2261e98d8e7d0899f2c9266819bc732c83b..a093fd5792350bd643e236f9223f590441f839fe 100644 (file)
@@ -290,8 +290,6 @@ maildir_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
        mbox->maildir_ext_id =
                mail_index_ext_register(mbox->box.index, "maildir",
                                        sizeof(mbox->maildir_hdr), 0, 0);
-       mbox->uidlist = maildir_uidlist_init(mbox);
-       mbox->keywords = maildir_keywords_init(mbox);
        return &mbox->box;
 }
 
@@ -301,6 +299,9 @@ static int maildir_mailbox_open_existing(struct mailbox *box)
        struct stat st;
        const char *shared_path;
 
+       mbox->uidlist = maildir_uidlist_init(mbox);
+       mbox->keywords = maildir_keywords_init(mbox);
+
        shared_path = t_strconcat(box->path, "/dovecot-shared", NULL);
        if (stat(shared_path, &st) == 0)
                box->private_flags_mask = MAIL_SEEN;
@@ -578,6 +579,7 @@ struct mailbox maildir_mailbox = {
                index_storage_mailbox_enable,
                maildir_mailbox_open,
                maildir_mailbox_close,
+               NULL,
                maildir_mailbox_create,
                maildir_mailbox_update,
                index_storage_mailbox_delete,
index 6e9adf6c0373f4d59c1b20cef52796f5fde66607..37e43fee2ce572abe64c9f3eb6b64ccd691eb12e 100644 (file)
@@ -693,6 +693,7 @@ struct mailbox mbox_mailbox = {
                index_storage_mailbox_enable,
                mbox_mailbox_open,
                mbox_mailbox_close,
+               NULL,
                mbox_mailbox_create,
                mbox_mailbox_update,
                index_storage_mailbox_delete,
index 101ca45cbb624dba1408c01478ef92671ce4dd67..28f842e38ae83b963bc66e904b757246ab5f4c11 100644 (file)
@@ -134,6 +134,7 @@ struct mailbox raw_mailbox = {
                index_storage_mailbox_enable,
                raw_mailbox_open,
                index_storage_mailbox_close,
+               NULL,
                raw_mailbox_create,
                raw_mailbox_update,
                index_storage_mailbox_delete,
index 93961d2f832797046d61a753864ff7e125856980..112c96856598141a86faa76621dafb13cb388e67 100644 (file)
@@ -93,6 +93,7 @@ struct mailbox_vfuncs {
        int (*enable)(struct mailbox *box, enum mailbox_feature features);
        int (*open)(struct mailbox *box);
        void (*close)(struct mailbox *box);
+       void (*free)(struct mailbox *box);
 
        int (*create)(struct mailbox *box, const struct mailbox_update *update,
                      bool directory);
index aaf9e2ad1966305bd022af45f3d747b111c22152..72be02ccea905212cdf6032e936228e17c04761e 100644 (file)
@@ -580,6 +580,9 @@ void mailbox_free(struct mailbox **_box)
        *_box = NULL;
 
        mailbox_close(box);
+
+       if (box->v.free != NULL)
+               box->v.free(box);
        mail_index_alloc_cache_unref(&box->index);
        pool_unref(&box->pool);
 }
index cd1bfe0e68841e2616c4dc893b2df650263f09b8..1da2e5703704dbd4f1fc81fb50539a988a996d89 100644 (file)
@@ -322,6 +322,7 @@ struct mailbox test_mailbox = {
                test_mailbox_enable,
                test_mailbox_open,
                test_mailbox_close,
+               NULL,
                test_mailbox_create,
                test_mailbox_update,
                test_mailbox_delete,
index 81ab8ed4ee09d1d105be5344531eda883660db62..c70af184bb2fa34b12aeda4ae62d94bd7aea0125 100644 (file)
@@ -97,12 +97,12 @@ static bool acl_allow_new_keywords(struct mailbox *box)
        return acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE) > 0;
 }
 
-static void acl_mailbox_close(struct mailbox *box)
+static void acl_mailbox_free(struct mailbox *box)
 {
        struct acl_mailbox *abox = ACL_CONTEXT(box);
 
        acl_object_deinit(&abox->aclobj);
-       abox->module_ctx.super.close(box);
+       abox->module_ctx.super.free(box);
 }
 
 static void acl_mailbox_copy_acls_from_parent(struct mailbox *box)
@@ -518,7 +518,7 @@ void acl_mailbox_allocated(struct mailbox *box)
                box->v.is_readonly = acl_is_readonly;
                box->v.allow_new_keywords = acl_allow_new_keywords;
                box->v.open = acl_mailbox_open;
-               box->v.close = acl_mailbox_close;
+               box->v.free = acl_mailbox_free;
                box->v.create = acl_mailbox_create;
                box->v.update = acl_mailbox_update;
                box->v.delete = acl_mailbox_delete;
index d3b2351c19fff82115af32937a87d2024e0eb6d0..5ed941c5801c207ba5ce68170fbb0d18096700db 100644 (file)
@@ -59,7 +59,7 @@ static MODULE_CONTEXT_DEFINE_INIT(fts_storage_module,
                                  &mail_storage_module_register);
 static MODULE_CONTEXT_DEFINE_INIT(fts_mail_module, &mail_module_register);
 
-static void fts_mailbox_close(struct mailbox *box)
+static void fts_mailbox_free(struct mailbox *box)
 {
        struct fts_mailbox *fbox = FTS_CONTEXT(box);
 
@@ -68,7 +68,7 @@ static void fts_mailbox_close(struct mailbox *box)
        if (fbox->backend_fast != NULL)
                fts_backend_deinit(&fbox->backend_fast);
 
-       fbox->module_ctx.super.close(box);
+       fbox->module_ctx.super.free(box);
        i_free(fbox);
 }
 
@@ -1028,7 +1028,7 @@ static void fts_mailbox_init(struct mailbox *box, const char *env)
        fbox->virtual = strcmp(box->storage->name, "virtual") == 0;
        fbox->env = env;
        fbox->module_ctx.super = box->v;
-       box->v.close = fts_mailbox_close;
+       box->v.free = fts_mailbox_free;
        box->v.search_init = fts_mailbox_search_init;
        box->v.search_next_nonblock = fts_mailbox_search_next_nonblock;
        box->v.search_next_update_seq = fbox->virtual ?
index 738491a38b8bdbf85faa7fcb97ab6d3cd4fcfa79..8ca52af123c887653c15d6dac1be575f7e9b870b 100644 (file)
@@ -373,7 +373,7 @@ static int quota_mailbox_delete(struct mailbox *box)
        return qbox->module_ctx.super.delete(box);
 }
 
-static void quota_mailbox_close(struct mailbox *box)
+static void quota_mailbox_free(struct mailbox *box)
 {
        struct quota_mailbox *qbox = QUOTA_CONTEXT(box);
 
@@ -384,7 +384,7 @@ static void quota_mailbox_close(struct mailbox *box)
        i_assert(qbox->expunge_qt == NULL ||
                 qbox->expunge_qt->tmp_mail == NULL);
 
-       qbox->module_ctx.super.close(box);
+       qbox->module_ctx.super.free(box);
 }
 
 void quota_mailbox_allocated(struct mailbox *box)
@@ -407,7 +407,7 @@ void quota_mailbox_allocated(struct mailbox *box)
        box->v.sync_notify = quota_mailbox_sync_notify;
        box->v.sync_deinit = quota_mailbox_sync_deinit;
        box->v.delete = quota_mailbox_delete;
-       box->v.close = quota_mailbox_close;
+       box->v.free = quota_mailbox_free;
        MODULE_CONTEXT_SET(box, quota_storage_module, qbox);
 }
 
index 60a92b5c4925f6a0e40d7a6dc11e97341de99ce7..397095ab22c2ff46ab927e5c6726fa516bc364bb 100644 (file)
@@ -445,6 +445,7 @@ struct mailbox virtual_mailbox = {
                index_storage_mailbox_enable,
                virtual_mailbox_open,
                virtual_mailbox_close,
+               NULL,
                virtual_mailbox_create,
                virtual_mailbox_update,
                index_storage_mailbox_delete,