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.
/* 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
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;
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);