From: Timo Sirainen Date: Thu, 2 Apr 2020 21:41:55 +0000 (+0300) Subject: lib-storage: Use mailbox.event as parent to mail_index X-Git-Tag: 2.3.11.2~369 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=05d9cb7dc128d103f2d5b99c466f7668df3abde1;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Use mailbox.event as parent to mail_index 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. --- diff --git a/src/lib-storage/index/index-rebuild.c b/src/lib-storage/index/index-rebuild.c index ac32531a73..17a5e43a7a 100644 --- a/src/lib-storage/index/index-rebuild.c +++ b/src/lib-storage/index/index-rebuild.c @@ -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 diff --git a/src/lib-storage/index/index-storage.c b/src/lib-storage/index/index-storage.c index e0145472d2..57a6559944 100644 --- a/src/lib-storage/index/index-storage.c +++ b/src/lib-storage/index/index-storage.c @@ -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; diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index da49488d9b..3561c149a9 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -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);