Skip to content

Commit

Permalink
global: Add mailbox_set_reason() calls
Browse files Browse the repository at this point in the history
Added to the most important places.
  • Loading branch information
sirainen committed Apr 3, 2017
1 parent b6726ae commit 1365792
Show file tree
Hide file tree
Showing 39 changed files with 57 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/doveadm/doveadm-mail-copymove.c
Expand Up @@ -108,6 +108,7 @@ cmd_copy_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user)

ns = mail_namespace_find(user->namespaces, ctx->destname);
destbox = mailbox_alloc(ns->list, ctx->destname, MAILBOX_FLAG_SAVEONLY);
mailbox_set_reason(destbox, _ctx->cmd->name);
if (mailbox_open(destbox) < 0) {
i_error("Can't open mailbox '%s': %s", ctx->destname,
mailbox_get_last_internal_error(destbox, NULL));
Expand Down
1 change: 1 addition & 0 deletions src/doveadm/doveadm-mail-import.c
Expand Up @@ -63,6 +63,7 @@ dest_mailbox_open_or_create(struct import_cmd_context *ctx,
}

box = mailbox_alloc(ns->list, name, MAILBOX_FLAG_SAVEONLY);
mailbox_set_reason(*box_r, ctx->ctx.cmd->name);
if (mailbox_create(box, NULL, FALSE) < 0) {
errstr = mailbox_get_last_internal_error(box, &error);
if (error != MAIL_ERROR_EXISTS) {
Expand Down
1 change: 1 addition & 0 deletions src/doveadm/doveadm-mail-index.c
Expand Up @@ -106,6 +106,7 @@ cmd_index_box(struct index_cmd_context *ctx, const struct mailbox_info *info)

box = mailbox_alloc(info->ns->list, info->vname,
MAILBOX_FLAG_IGNORE_ACLS);
mailbox_set_reason(box, ctx->ctx.cmd->name);
if (ctx->max_recent_msgs != 0) {
/* index only if there aren't too many recent messages.
don't bother syncing the mailbox, that alone can take a
Expand Down
1 change: 1 addition & 0 deletions src/doveadm/doveadm-mail-iter.c
Expand Up @@ -37,6 +37,7 @@ int doveadm_mail_iter_init(struct doveadm_mail_cmd_context *ctx,
iter->ctx = ctx;
iter->box = mailbox_alloc(info->ns->list, info->vname,
MAILBOX_FLAG_IGNORE_ACLS | readonly_flag);
mailbox_set_reason(iter->box, ctx->cmd->name);
iter->search_args = search_args;

if (mailbox_sync(iter->box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) {
Expand Down
1 change: 1 addition & 0 deletions src/doveadm/doveadm-mail-mailbox-metadata.c
Expand Up @@ -46,6 +46,7 @@ cmd_mailbox_metadata_open_mailbox(struct metadata_cmd_context *mctx,
*ns_r = mail_namespace_find(user->namespaces, mctx->mailbox);
*box_r = mailbox_alloc((*ns_r)->list, mctx->mailbox, 0);
}
mailbox_set_reason(*box_r, mctx->ctx.cmd->name);

if (mailbox_open(*box_r) < 0) {
i_error("Failed to open mailbox: %s",
Expand Down
1 change: 1 addition & 0 deletions src/doveadm/doveadm-mail-mailbox-status.c
Expand Up @@ -127,6 +127,7 @@ status_mailbox(struct status_cmd_context *ctx, const struct mailbox_info *info)
struct mailbox_metadata metadata;

box = doveadm_mailbox_find(ctx->ctx.cur_mail_user, info->vname);
mailbox_set_reason(box, ctx->ctx.cmd->name);
if (mailbox_get_status(box, ctx->status_items, &status) < 0 ||
mailbox_get_metadata(box, ctx->metadata_items, &metadata) < 0) {
i_error("Mailbox %s: Failed to lookup mailbox status: %s",
Expand Down
6 changes: 6 additions & 0 deletions src/doveadm/doveadm-mail-mailbox.c
Expand Up @@ -242,6 +242,7 @@ cmd_mailbox_create_run(struct doveadm_mail_cmd_context *_ctx,
}

box = mailbox_alloc(ns->list, name, 0);
mailbox_set_reason(box, _ctx->cmd->name);
if (mailbox_create(box, &ctx->update, directory) < 0) {
i_error("Can't create mailbox %s: %s", name,
mailbox_get_last_internal_error(box, NULL));
Expand Down Expand Up @@ -372,6 +373,7 @@ cmd_mailbox_delete_run(struct doveadm_mail_cmd_context *_ctx,

ns = mail_namespace_find(user->namespaces, name);
box = mailbox_alloc(ns->list, name, mailbox_flags);
mailbox_set_reason(box, _ctx->cmd->name);
storage = mailbox_get_storage(box);
ret2 = ctx->require_empty ? mailbox_delete_empty(box) :
mailbox_delete(box);
Expand Down Expand Up @@ -464,6 +466,8 @@ cmd_mailbox_rename_run(struct doveadm_mail_cmd_context *_ctx,
newns = mail_namespace_find(user->namespaces, newname);
oldbox = mailbox_alloc(oldns->list, oldname, 0);
newbox = mailbox_alloc(newns->list, newname, 0);
mailbox_set_reason(oldbox, _ctx->cmd->name);
mailbox_set_reason(newbox, _ctx->cmd->name);
if (mailbox_rename(oldbox, newbox) < 0) {
i_error("Can't rename mailbox %s to %s: %s", oldname, newname,
mailbox_get_last_internal_error(oldbox, NULL));
Expand Down Expand Up @@ -528,6 +532,7 @@ cmd_mailbox_subscribe_run(struct doveadm_mail_cmd_context *_ctx,

ns = mail_namespace_find(user->namespaces, name);
box = mailbox_alloc(ns->list, name, 0);
mailbox_set_reason(box, _ctx->cmd->name);
if (mailbox_set_subscribed(box, ctx->ctx.subscriptions) < 0) {
i_error("Can't %s mailbox %s: %s", name,
ctx->ctx.subscriptions ? "subscribe to" :
Expand Down Expand Up @@ -655,6 +660,7 @@ int cmd_mailbox_update_run(struct doveadm_mail_cmd_context *_ctx,

ns = mail_namespace_find(user->namespaces, ctx->mailbox);
box = mailbox_alloc(ns->list, ctx->mailbox, 0);
mailbox_set_reason(box, _ctx->cmd->name);

if ((ret = mailbox_update(box, &(ctx->update))) != 0) {
i_error("Cannot update %s: %s",
Expand Down
1 change: 1 addition & 0 deletions src/doveadm/doveadm-mail-save.c
Expand Up @@ -90,6 +90,7 @@ cmd_save_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user)

ns = mail_namespace_find(user->namespaces, ctx->mailbox);
box = mailbox_alloc(ns->list, ctx->mailbox, MAILBOX_FLAG_SAVEONLY);
mailbox_set_reason(box, _ctx->cmd->name);
ret = cmd_save_to_mailbox(ctx, box, _ctx->cmd_input);
mailbox_free(&box);
return ret;
Expand Down
1 change: 1 addition & 0 deletions src/doveadm/doveadm-mail.c
Expand Up @@ -285,6 +285,7 @@ static int cmd_force_resync_box(struct doveadm_mail_cmd_context *ctx,

box = mailbox_alloc(info->ns->list, info->vname,
MAILBOX_FLAG_IGNORE_ACLS);
mailbox_set_reason(box, ctx->cmd->name);
if (mailbox_open(box) < 0) {
i_error("Opening mailbox %s failed: %s", info->vname,
mailbox_get_last_internal_error(box, NULL));
Expand Down
1 change: 1 addition & 0 deletions src/imap/cmd-create.c
Expand Up @@ -38,6 +38,7 @@ bool cmd_create(struct client_command_context *cmd)
}

box = mailbox_alloc(ns->list, mailbox, 0);
mailbox_set_reason(box, "CREATE");
if (mailbox_create(box, NULL, directory) < 0)
client_send_box_error(cmd, box);
else
Expand Down
1 change: 1 addition & 0 deletions src/imap/cmd-delete.c
Expand Up @@ -21,6 +21,7 @@ bool cmd_delete(struct client_command_context *cmd)
return TRUE;

box = mailbox_alloc(ns->list, name, 0);
mailbox_set_reason(box, "DELETE");
if (mailbox_is_any_inbox(box)) {
/* IMAP protocol allows this, but I think it's safer to
not allow it. */
Expand Down
1 change: 1 addition & 0 deletions src/imap/cmd-getmetadata.c
Expand Up @@ -410,6 +410,7 @@ cmd_getmetadata_try_mailbox(struct imap_getmetadata_context *ctx,
struct mail_namespace *ns, const char *mailbox)
{
ctx->box = mailbox_alloc(ns->list, mailbox, MAILBOX_FLAG_READONLY);
mailbox_set_reason(ctx->box, "GETMETADATA");
if (mailbox_open(ctx->box) < 0)
return -1;

Expand Down
1 change: 1 addition & 0 deletions src/imap/cmd-notify.c
Expand Up @@ -417,6 +417,7 @@ imap_notify_box_send_status(struct client_command_context *cmd,
items.status |= STATUS_HIGHESTMODSEQ;

box = mailbox_alloc(info->ns->list, info->vname, MAILBOX_FLAG_READONLY);
mailbox_set_reason(box, "NOTIFY send STATUS");
if (ctx->client->enabled_features != 0)
(void)mailbox_enable(box, ctx->client->enabled_features);

Expand Down
2 changes: 2 additions & 0 deletions src/imap/cmd-rename.c
Expand Up @@ -37,6 +37,8 @@ bool cmd_rename(struct client_command_context *cmd)

old_box = mailbox_alloc(old_ns->list, oldname, 0);
new_box = mailbox_alloc(new_ns->list, newname, 0);
mailbox_set_reason(old_box, "RENAME from");
mailbox_set_reason(new_box, "RENAME to");
if (mailbox_rename(old_box, new_box) < 0)
client_send_box_error(cmd, old_box);
else
Expand Down
1 change: 1 addition & 0 deletions src/imap/cmd-resetkey.c
Expand Up @@ -49,6 +49,7 @@ cmd_resetkey_mailbox(struct client_command_context *cmd,

/* open mailbox */
box = mailbox_alloc(ns->list, mailbox, flags);
mailbox_set_reason(box, "RESETKEY");
if (mailbox_open(box) < 0) {
client_send_box_error(cmd, box);
mailbox_free(&box);
Expand Down
1 change: 1 addition & 0 deletions src/imap/cmd-select.c
Expand Up @@ -291,6 +291,7 @@ select_open(struct imap_select_context *ctx, const char *mailbox, bool readonly)
else
flags |= MAILBOX_FLAG_DROP_RECENT;
ctx->box = mailbox_alloc(ctx->ns->list, mailbox, flags);
mailbox_set_reason(ctx->box, readonly ? "EXAMINE" : "SELECT");
if (mailbox_open(ctx->box) < 0) {
client_send_box_error(ctx->cmd, ctx->box);
mailbox_free(&ctx->box);
Expand Down
1 change: 1 addition & 0 deletions src/imap/cmd-setmetadata.c
Expand Up @@ -304,6 +304,7 @@ cmd_setmetadata_mailbox(struct imap_setmetadata_context *ctx,
ctx->box = client->mailbox;
else {
ctx->box = mailbox_alloc(ns->list, mailbox, 0);
mailbox_set_reason(ctx->box, "SETMETADATA");
if (mailbox_open(ctx->box) < 0) {
client_send_box_error(cmd, ctx->box);
mailbox_free(&ctx->box);
Expand Down
2 changes: 2 additions & 0 deletions src/imap/cmd-subscribe.c
Expand Up @@ -49,6 +49,7 @@ bool cmd_subscribe_full(struct client_command_context *cmd, bool subscribe)
return TRUE;

box = mailbox_alloc(ns->list, mailbox, 0);
mailbox_set_reason(box, subscribe ? "SUBSCRIBE" : "UNSUBSCRIBE");
if (subscribe) {
if (!subscribe_is_valid_name(cmd, box)) {
mailbox_free(&box);
Expand All @@ -64,6 +65,7 @@ bool cmd_subscribe_full(struct client_command_context *cmd, bool subscribe)
/* try to unsubscribe both "box" and "box/" */
const char *name2 = t_strdup_printf("%s%c", mailbox, sep);
box2 = mailbox_alloc(ns->list, name2, 0);
mailbox_set_reason(box2, "UNSUBSCRIBE");
if (mailbox_set_subscribed(box2, FALSE) == 0)
unsubscribed_mailbox2 = TRUE;
mailbox_free(&box2);
Expand Down
1 change: 1 addition & 0 deletions src/imap/imap-commands-util.c
Expand Up @@ -109,6 +109,7 @@ int client_open_save_dest_box(struct client_command_context *cmd,
return 0;
}
box = mailbox_alloc(ns->list, name, MAILBOX_FLAG_SAVEONLY);
mailbox_set_reason(box, cmd->name);
if (mailbox_open(box) < 0) {
error_string = mailbox_get_last_error(box, &error);
if (error == MAIL_ERROR_NOTFOUND) {
Expand Down
2 changes: 2 additions & 0 deletions src/imap/imap-notify.c
Expand Up @@ -57,6 +57,7 @@ static int imap_notify_status(struct imap_notify_namespace *notify_ns,
items.status |= STATUS_HIGHESTMODSEQ;

box = mailbox_alloc(notify_ns->ns->list, rec->vname, 0);
mailbox_set_reason(box, "NOTIFY STATUS");
if ((rec->events & MAILBOX_LIST_NOTIFY_UIDVALIDITY) != 0) {
items.status |= STATUS_UIDVALIDITY | STATUS_UIDNEXT |
STATUS_MESSAGES | STATUS_UNSEEN;
Expand Down Expand Up @@ -197,6 +198,7 @@ bool imap_notify_match_mailbox(struct imap_notify_namespace *notify_ns,
switch (notify_boxes->type) {
case IMAP_NOTIFY_TYPE_SUBSCRIBED:
box = mailbox_alloc(notify_ns->ns->list, vname, 0);
mailbox_set_reason(box, "NOTIFY is subscribed");
ret = mailbox_is_subscribed(box);
mailbox_free(&box);
return ret;
Expand Down
1 change: 1 addition & 0 deletions src/imap/imap-state.c
Expand Up @@ -573,6 +573,7 @@ import_state_mailbox_open(struct client *client,
else
flags |= MAILBOX_FLAG_DROP_RECENT;
box = mailbox_alloc(ns->list, state->vname, flags);
mailbox_set_reason(box, "unhibernate");
if (mailbox_open(box) < 0) {
*error_r = t_strdup_printf("Couldn't open mailbox: %s",
mailbox_get_last_internal_error(box, NULL));
Expand Down
1 change: 1 addition & 0 deletions src/imap/imap-status.c
Expand Up @@ -74,6 +74,7 @@ int imap_status_get(struct client_command_context *cmd,
} else {
/* open the mailbox */
box = mailbox_alloc(ns->list, mailbox, MAILBOX_FLAG_READONLY);
mailbox_set_reason(box, "STATUS");
if (client->enabled_features != 0)
(void)mailbox_enable(box, client->enabled_features);
}
Expand Down
1 change: 1 addition & 0 deletions src/indexer/master-connection.c
Expand Up @@ -142,6 +142,7 @@ index_mailbox(struct master_connection *conn, struct mail_user *user,

ns = mail_namespace_find(user->namespaces, mailbox);
box = mailbox_alloc(ns->list, mailbox, 0);
mailbox_set_reason(box, "indexing");
ret = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX, &path);
if (ret < 0) {
i_error("Getting path to mailbox %s failed: %s",
Expand Down
1 change: 1 addition & 0 deletions src/lib-imap-storage/imap-metadata.c
Expand Up @@ -244,6 +244,7 @@ imap_metadata_transaction_begin_server(struct mail_user *user)

ns = mail_namespace_find_inbox(user->namespaces);
box = mailbox_alloc(ns->list, "INBOX", 0);
mailbox_set_reason(box, "Server METADATA");
imtrans = imap_metadata_transaction_begin(box);
imtrans->server = TRUE;
return imtrans;
Expand Down
4 changes: 3 additions & 1 deletion src/lib-imap-storage/imap-msgpart-url.c
Expand Up @@ -129,8 +129,10 @@ int imap_msgpart_url_open_mailbox(struct imap_msgpart_url *mpurl,
if (mpurl->selected_box != NULL &&
mailbox_equals(mpurl->selected_box, ns, mpurl->mailbox))
box = mpurl->selected_box;
else
else {
box = mailbox_alloc(ns->list, mpurl->mailbox, flags);
mailbox_set_reason(box, "Read IMAP URL");
}
if (mailbox_open(box) < 0) {
*error_r = mail_storage_get_last_error(mailbox_get_storage(box),
error_code_r);
Expand Down
1 change: 1 addition & 0 deletions src/lib-imap-urlauth/imap-urlauth-backend.c
Expand Up @@ -132,6 +132,7 @@ int imap_urlauth_backend_reset_all_keys(struct mail_user *user)
MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
while ((info = mailbox_list_iter_next(iter)) != NULL) {
box = mailbox_alloc(info->ns->list, info->vname, 0);
mailbox_set_reason(box, "URLAUTH reset all keys");
if (imap_urlauth_backend_mailbox_reset_key(box) < 0)
ret = -1;
mailbox_free(&box);
Expand Down
2 changes: 2 additions & 0 deletions src/lib-lda/mail-deliver.c
Expand Up @@ -230,6 +230,7 @@ int mail_deliver_save_open(struct mail_deliver_save_open_context *ctx,
}

*box_r = box = mailbox_alloc(ns->list, name, flags);
mailbox_set_reason(box, "lib-lda delivery");
/* flag that this mailbox is used for delivering the mail.
the context isn't set in pigeonhole testuite. */
struct mail_deliver_mailbox *mbox = MAIL_DELIVER_STORAGE_CONTEXT(box);
Expand Down Expand Up @@ -574,6 +575,7 @@ mail_deliver_cache_update_post_commit(struct mailbox *orig_box, uint32_t uid)
synced, so it'll contain the newly written mail. this is racy, so
it's possible another process has already deleted the mail. */
box = mailbox_alloc(orig_box->list, orig_box->vname, 0);
mailbox_set_reason(box, "lib-lda storage-id");

mail = mail_deliver_open_mail(box, uid, MAIL_FETCH_STORAGE_ID, &t);
if (mail != NULL) {
Expand Down
2 changes: 2 additions & 0 deletions src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
Expand Up @@ -551,6 +551,7 @@ rebuild_mailbox(struct mdbox_storage_rebuild_context *ctx,

box = mailbox_alloc(ns->list, vname, MAILBOX_FLAG_READONLY |
MAILBOX_FLAG_IGNORE_ACLS);
mailbox_set_reason(box, "mdbox rebuild");
if (box->storage != &ctx->storage->storage.storage) {
/* the namespace has multiple storages. */
mailbox_free(&box);
Expand Down Expand Up @@ -703,6 +704,7 @@ static int rebuild_restore_msg(struct mdbox_storage_rebuild_context *ctx,
box = mailbox_alloc(ctx->default_list, mailbox,
MAILBOX_FLAG_READONLY |
MAILBOX_FLAG_IGNORE_ACLS);
mailbox_set_reason(box, "mdbox rebuild restore");
i_assert(box->storage == storage);
if (mailbox_open(box) == 0)
break;
Expand Down
1 change: 1 addition & 0 deletions src/lib-storage/mail-autoexpunge.c
Expand Up @@ -156,6 +156,7 @@ mailbox_autoexpunge_set(struct mail_namespace *ns, const char *vname,
any ACLs the user might normally have against expunging in
the mailbox. */
box = mailbox_alloc(ns->list, vname, MAILBOX_FLAG_IGNORE_ACLS);
mailbox_set_reason(box, "autoexpunge");
if (mailbox_autoexpunge(box, autoexpunge, autoexpunge_max_mails,
expunged_count) < 0) {
i_error("Failed to autoexpunge mailbox '%s': %s",
Expand Down
1 change: 1 addition & 0 deletions src/lib-storage/mail-storage.c
Expand Up @@ -1389,6 +1389,7 @@ static void mailbox_copy_cache_decisions_from_inbox(struct mailbox *box)

/* this should be NoSelect but since inbox can never be
NoSelect we use EXISTENCE_NONE to avoid creating inbox by accident */
mailbox_set_reason(inbox, "copy caching decisions");
if (mailbox_exists(inbox, FALSE, &existence) == 0 &&
existence != MAILBOX_EXISTENCE_NONE &&
mailbox_open(inbox) == 0 &&
Expand Down
1 change: 1 addition & 0 deletions src/lmtp/commands.c
Expand Up @@ -583,6 +583,7 @@ lmtp_rcpt_to_is_over_quota(struct client *client,

ns = mail_namespace_find_inbox(user->namespaces);
box = mailbox_alloc(ns->list, "INBOX", 0);
mailbox_set_reason(box, "over-quota check");
ret = mailbox_get_status(box, STATUS_CHECK_OVER_QUOTA, &status);
if (ret < 0) {
errstr = mailbox_get_last_error(box, &error);
Expand Down
1 change: 1 addition & 0 deletions src/plugins/lazy-expunge/lazy-expunge-plugin.c
Expand Up @@ -119,6 +119,7 @@ mailbox_open_or_create(struct mailbox_list *list, struct mailbox *src_box,

box = mailbox_alloc(list, name, MAILBOX_FLAG_NO_INDEX_FILES |
MAILBOX_FLAG_SAVEONLY | MAILBOX_FLAG_IGNORE_ACLS);
mailbox_set_reason(box, "lazy_expunge");
if (mailbox_open(box) == 0) {
*error_r = NULL;
return box;
Expand Down
7 changes: 5 additions & 2 deletions src/plugins/pop3-migration/pop3-migration-plugin.c
Expand Up @@ -311,12 +311,15 @@ static struct mailbox *pop3_mailbox_alloc(struct mail_storage *storage)
struct pop3_migration_mail_storage *mstorage =
POP3_MIGRATION_CONTEXT(storage);
struct mail_namespace *ns;
struct mailbox *box;

ns = mail_namespace_find(storage->user->namespaces,
mstorage->pop3_box_vname);
i_assert(ns != NULL);
return mailbox_alloc(ns->list, mstorage->pop3_box_vname,
MAILBOX_FLAG_READONLY | MAILBOX_FLAG_POP3_SESSION);
box = mailbox_alloc(ns->list, mstorage->pop3_box_vname,
MAILBOX_FLAG_READONLY | MAILBOX_FLAG_POP3_SESSION);
mailbox_set_reason(box, "pop3_migration");
return box;
}

static int pop3_map_read(struct mail_storage *storage, struct mailbox *pop3_box)
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/quota/quota-count.c
Expand Up @@ -42,6 +42,7 @@ quota_count_mailbox(struct quota_root *root, struct mail_namespace *ns,
}

box = mailbox_alloc(ns->list, vname, MAILBOX_FLAG_READONLY);
mailbox_set_reason(box, "quota count");
if ((box->storage->class_flags & MAIL_STORAGE_CLASS_FLAG_NOQUOTA) != 0) {
/* quota doesn't exist for this mailbox/storage */
ret = 0;
Expand Down Expand Up @@ -295,6 +296,7 @@ static int quota_count_recalculate(struct quota_root *root)
iter = quota_mailbox_iter_begin(root);
while ((info = quota_mailbox_iter_next(iter)) != NULL) {
box = mailbox_alloc(info->ns->list, info->vname, 0);
mailbox_set_reason(box, "quota recalculate");
if (quota_count_recalculate_box(box) < 0)
ret = -1;
mailbox_free(&box);
Expand Down
1 change: 1 addition & 0 deletions src/plugins/quota/quota-status.c
Expand Up @@ -61,6 +61,7 @@ quota_check(struct mail_user *user, uoff_t mail_size, const char **error_r)

ns = mail_namespace_find_inbox(user->namespaces);
box = mailbox_alloc(ns->list, "INBOX", MAILBOX_FLAG_POST_SESSION);
mailbox_set_reason(box, "quota status");

ctx = quota_transaction_begin(box);
ret = quota_test_alloc(ctx, I_MAX(1, mail_size));
Expand Down
1 change: 1 addition & 0 deletions src/plugins/trash/trash-plugin.c
Expand Up @@ -52,6 +52,7 @@ static int trash_clean_mailbox_open(struct trash_mailbox *trash)
struct mail_search_args *search_args;

trash->box = mailbox_alloc(trash->ns->list, trash->name, 0);
mailbox_set_reason(trash->box, "trash plugin");
if (mailbox_open(trash->box) < 0) {
mailbox_free(&trash->box);
return 0;
Expand Down
1 change: 1 addition & 0 deletions src/plugins/virtual/virtual-config.c
Expand Up @@ -373,6 +373,7 @@ virtual_config_metadata_match(const struct mailbox_info *info,
return 1;

box = mailbox_alloc(info->ns->list, info->vname, MAILBOX_FLAG_READONLY);
mailbox_set_reason(box, "virtual mailbox metadata match");
for (i = 0; i < count; i++) {
if ((ret = virtual_config_box_metadata_match(box, boxes[i], error_r)) <= 0)
break;
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/virtual/virtual-storage.c
Expand Up @@ -192,6 +192,8 @@ static int virtual_backend_box_alloc(struct virtual_mailbox *mbox,
ns = mail_namespace_find(user->namespaces, mailbox);
bbox->box = mailbox_alloc(ns->list, mailbox, flags);
MODULE_CONTEXT_SET(bbox->box, virtual_storage_module, bbox);
mailbox_set_reason(bbox->box, mbox->box.reason == NULL ? "virtual mailbox" :
t_strdup_printf("virtual mailbox: %s", mbox->box.reason));

if (mailbox_exists(bbox->box, TRUE, &existence) < 0)
return virtual_backend_box_open_failed(mbox, bbox);
Expand Down

0 comments on commit 1365792

Please sign in to comment.