]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Use mailbox.event as parent to mail_index
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 2 Apr 2020 21:41:55 +0000 (00:41 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Apr 2020 09:41:43 +0000 (12:41 +0300)
The index lives longer than the struct mailbox, which is a bit confusing.
In some cases the index could even be used for a different mailbox name
(symlink/alias), in which case the event's mailbox name wouldn't be exactly
correct. However, these downsides are still preferable to not inheriting
from the mailbox event, since then there is no mailbox name.

src/lib-storage/index/index-rebuild.c
src/lib-storage/index/index-storage.c
src/lib-storage/mail-storage.c

index ac32531a73c13533473fdb7266f4d7e00e074741..17a5e43a7aed069850b15ddb90bca4bf119c23e4 100644 (file)
@@ -214,7 +214,7 @@ index_index_rebuild_init(struct mailbox *box, struct mail_index_view *view,
        /* if backup index file exists, try to use it */
        index_dir = mailbox_get_index_path(box);
        backup_path = t_strconcat(box->index_prefix, ".backup", NULL);
-       ctx->backup_index = mail_index_alloc(box->storage->event,
+       ctx->backup_index = mail_index_alloc(box->event,
                                             index_dir, backup_path);
 
 #ifndef MMAP_CONFLICTS_WRITE
index e0145472d2b67736ad26a7a8cbeec5d9c16624db..57a6559944a24fa284b96b42c9bb09939b1114e9 100644 (file)
@@ -161,7 +161,8 @@ index_mailbox_alloc_index(struct mailbox *box, struct mail_index **index_r)
            mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX,
                                &index_dir) <= 0)
                index_dir = NULL;
-       *index_r = mail_index_alloc_cache_get(box->storage->event,
+       /* Note that this may cause box->event to live longer than box */
+       *index_r = mail_index_alloc_cache_get(box->event,
                                              mailbox_path, index_dir,
                                              box->index_prefix);
        return 0;
index da49488d9b094e386ac4b38f2c0ce370e7cc1003..3561c149a92d32907c5bdde2da0778c6b7075910 100644 (file)
@@ -1539,7 +1539,8 @@ static int mailbox_alloc_index_pvt(struct mailbox *box)
        if (mailbox_create_missing_dir(box, MAILBOX_LIST_PATH_TYPE_INDEX_PRIVATE) < 0)
                return -1;
 
-       box->index_pvt = mail_index_alloc_cache_get(box->storage->event,
+       /* Note that this may cause box->event to live longer than box */
+       box->index_pvt = mail_index_alloc_cache_get(box->event,
                NULL, index_dir, t_strconcat(box->index_prefix, ".pvt", NULL));
        mail_index_set_fsync_mode(box->index_pvt,
                                  box->storage->set->parsed_fsync_mode, 0);