From: Martti Rannanjärvi Date: Mon, 27 Nov 2017 12:19:34 +0000 (+0200) Subject: global: Use mail_set_critical() and mailbox_set_critical() if possible X-Git-Tag: 2.3.0.rc1~166 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4002fe1f64d25a792f76fb102ef7dc519cd4e24;p=thirdparty%2Fdovecot%2Fcore.git global: Use mail_set_critical() and mailbox_set_critical() if possible Replace calls to mail_storage_set_critical() with mail_set_critical() or mailbox_set_critical() in places where mailbox or mail are easily available. --- diff --git a/src/imap/cmd-append.c b/src/imap/cmd-append.c index a630b9c8de..ecb48623af 100644 --- a/src/imap/cmd-append.c +++ b/src/imap/cmd-append.c @@ -207,7 +207,7 @@ cmd_append_catenate_mpurl(struct client_command_context *cmd, } while (mailbox_save_continue(ctx->save_ctx) == 0 && ret != -1); if (mpresult.input->stream_errno != 0) { - mail_storage_set_critical(ctx->box->storage, + mailbox_set_critical(ctx->box, "read(%s) failed: %s (for CATENATE URL %s)", i_stream_get_name(mpresult.input), i_stream_get_error(mpresult.input), caturl); diff --git a/src/imap/imap-fetch-body.c b/src/imap/imap-fetch-body.c index ebe42b31f3..3711dd5520 100644 --- a/src/imap/imap-fetch-body.c +++ b/src/imap/imap-fetch-body.c @@ -37,12 +37,11 @@ static void fetch_read_error(struct imap_fetch_context *ctx, return; } } - mail_storage_set_critical(state->cur_mail->box->storage, - "read(%s) failed: %s (FETCH %s for mailbox %s UID %u)", + mail_set_critical(state->cur_mail, + "read(%s) failed: %s (FETCH %s)", i_stream_get_name(state->cur_input), i_stream_get_error(state->cur_input), - state->cur_human_name, - mailbox_get_vname(state->cur_mail->box), state->cur_mail->uid); + state->cur_human_name); *disconnect_reason_r = "FETCH read() failed"; } diff --git a/src/lib-imap-storage/imap-msgpart.c b/src/lib-imap-storage/imap-msgpart.c index 84e0773a9a..a92f39df37 100644 --- a/src/lib-imap-storage/imap-msgpart.c +++ b/src/lib-imap-storage/imap-msgpart.c @@ -399,7 +399,7 @@ imap_msgpart_get_partial_header(struct mail *mail, struct istream *mail_input, } if (message_get_header_size(input, &hdr_size, &has_nuls) < 0) { - mail_storage_set_critical(mail->box->storage, + mail_set_critical(mail, "read(%s) failed: %s", i_stream_get_name(input), i_stream_get_error(input)); i_stream_unref(&input); diff --git a/src/lib-storage/index/cydir/cydir-mail.c b/src/lib-storage/index/cydir/cydir-mail.c index cbac6956a4..49d8f17c47 100644 --- a/src/lib-storage/index/cydir/cydir-mail.c +++ b/src/lib-storage/index/cydir/cydir-mail.c @@ -33,8 +33,7 @@ static int cydir_mail_stat(struct mail *mail, struct stat *st_r) if (errno == ENOENT) mail_set_expunged(mail); else { - mail_storage_set_critical(mail->box->storage, - "stat(%s) failed: %m", path); + mail_set_critical(mail, "stat(%s) failed: %m", path); } return -1; } @@ -111,8 +110,8 @@ cydir_mail_get_stream(struct mail *_mail, bool get_body ATTR_UNUSED, if (errno == ENOENT) mail_set_expunged(_mail); else { - mail_storage_set_critical(_mail->box->storage, - "open(%s) failed: %m", path); + mail_set_critical(_mail, "open(%s) failed: %m", + path); } return -1; } diff --git a/src/lib-storage/index/cydir/cydir-save.c b/src/lib-storage/index/cydir/cydir-save.c index 323c4e3013..5aaf14c282 100644 --- a/src/lib-storage/index/cydir/cydir-save.c +++ b/src/lib-storage/index/cydir/cydir-save.c @@ -95,8 +95,8 @@ int cydir_save_begin(struct mail_save_context *_ctx, struct istream *input) o_stream_set_name(_ctx->data.output, path); o_stream_cork(_ctx->data.output); } else { - mail_storage_set_critical(trans->box->storage, - "open(%s) failed: %m", path); + mailbox_set_critical(trans->box, "open(%s) failed: %m", + path); ctx->failed = TRUE; } } T_END; @@ -143,19 +143,19 @@ int cydir_save_continue(struct mail_save_context *_ctx) static int cydir_save_flush(struct cydir_save_context *ctx, const char *path) { struct mail_storage *storage = &ctx->mbox->storage->storage; + struct mailbox *box = &ctx->mbox->box; struct stat st; int ret = 0; if (o_stream_finish(ctx->ctx.data.output) < 0) { - mail_storage_set_critical(storage, "write(%s) failed: %s", path, + mailbox_set_critical(box, "write(%s) failed: %s", path, o_stream_get_error(ctx->ctx.data.output)); ret = -1; } if (storage->set->parsed_fsync_mode != FSYNC_MODE_NEVER) { if (fsync(ctx->fd) < 0) { - mail_storage_set_critical(storage, - "fsync(%s) failed: %m", path); + mailbox_set_critical(box, "fsync(%s) failed: %m", path); ret = -1; } } @@ -164,8 +164,7 @@ static int cydir_save_flush(struct cydir_save_context *ctx, const char *path) if (fstat(ctx->fd, &st) == 0) ctx->ctx.data.received_date = st.st_mtime; else { - mail_storage_set_critical(storage, - "fstat(%s) failed: %m", path); + mailbox_set_critical(box, "fstat(%s) failed: %m", path); ret = -1; } } else { @@ -174,16 +173,14 @@ static int cydir_save_flush(struct cydir_save_context *ctx, const char *path) ut.actime = ioloop_time; ut.modtime = ctx->ctx.data.received_date; if (utime(path, &ut) < 0) { - mail_storage_set_critical(storage, - "utime(%s) failed: %m", path); + mailbox_set_critical(box, "utime(%s) failed: %m", path); ret = -1; } } o_stream_destroy(&ctx->ctx.data.output); if (close(ctx->fd) < 0) { - mail_storage_set_critical(storage, - "close(%s) failed: %m", path); + mailbox_set_critical(box, "close(%s) failed: %m", path); ret = -1; } ctx->fd = -1; @@ -267,7 +264,7 @@ int cydir_transaction_save_commit_pre(struct mail_save_context *_ctx) str_printfa(dest_path, "%u.", uid); if (rename(str_c(src_path), str_c(dest_path)) < 0) { - mail_storage_set_critical(&ctx->mbox->storage->storage, + mailbox_set_critical(&ctx->mbox->box, "rename(%s, %s) failed: %m", str_c(src_path), str_c(dest_path)); ctx->failed = TRUE; diff --git a/src/lib-storage/index/cydir/cydir-storage.c b/src/lib-storage/index/cydir/cydir-storage.c index eec578abb5..7843cff388 100644 --- a/src/lib-storage/index/cydir/cydir-storage.c +++ b/src/lib-storage/index/cydir/cydir-storage.c @@ -70,12 +70,11 @@ static int cydir_mailbox_open(struct mailbox *box) T_MAIL_ERR_MAILBOX_NOT_FOUND(box->vname)); return -1; } else if (errno == EACCES) { - mail_storage_set_critical(box->storage, "%s", + mailbox_set_critical(box, "%s", mail_error_eacces_msg("stat", box_path)); return -1; } else { - mail_storage_set_critical(box->storage, "stat(%s) failed: %m", - box_path); + mailbox_set_critical(box, "stat(%s) failed: %m", box_path); return -1; } if (index_storage_mailbox_open(box, FALSE) < 0) diff --git a/src/lib-storage/index/dbox-common/dbox-save.c b/src/lib-storage/index/dbox-common/dbox-save.c index 91424c8e2b..646d1df915 100644 --- a/src/lib-storage/index/dbox-common/dbox-save.c +++ b/src/lib-storage/index/dbox-common/dbox-save.c @@ -56,9 +56,9 @@ void dbox_save_begin(struct dbox_save_context *ctx, struct istream *input) o_stream_cork(ctx->dbox_output); if (o_stream_send(ctx->dbox_output, &dbox_msg_hdr, sizeof(dbox_msg_hdr)) < 0) { - mail_storage_set_critical(_storage, "write(%s) failed: %s", - o_stream_get_name(ctx->dbox_output), - o_stream_get_error(ctx->dbox_output)); + mail_set_critical(_ctx->dest_mail, "write(%s) failed: %s", + o_stream_get_name(ctx->dbox_output), + o_stream_get_error(ctx->dbox_output)); ctx->failed = TRUE; } _ctx->data.output = ctx->dbox_output; @@ -107,10 +107,10 @@ void dbox_save_end(struct dbox_save_context *ctx) ret = o_stream_flush(mdata->output); } if (ret < 0) { - mail_storage_set_critical(ctx->ctx.transaction->box->storage, - "write(%s) failed: %s", - o_stream_get_name(mdata->output), - o_stream_get_error(mdata->output)); + mail_set_critical(ctx->ctx.dest_mail, + "write(%s) failed: %s", + o_stream_get_name(mdata->output), + o_stream_get_error(mdata->output)); ctx->failed = TRUE; } if (mdata->output != dbox_output) { diff --git a/src/lib-storage/index/dbox-common/dbox-storage.c b/src/lib-storage/index/dbox-common/dbox-storage.c index 6eff972a0a..05f3f95246 100644 --- a/src/lib-storage/index/dbox-common/dbox-storage.c +++ b/src/lib-storage/index/dbox-common/dbox-storage.c @@ -246,12 +246,11 @@ int dbox_mailbox_check_existence(struct mailbox *box, time_t *path_ctime_r) T_MAIL_ERR_MAILBOX_NOT_FOUND(box->vname)); return -1; } else if (errno == EACCES) { - mail_storage_set_critical(box->storage, "%s", + mailbox_set_critical(box, "%s", mail_error_eacces_msg("stat", box_path)); return -1; } else { - mail_storage_set_critical(box->storage, - "stat(%s) failed: %m", box_path); + mailbox_set_critical(box, "stat(%s) failed: %m", box_path); return -1; } } @@ -334,10 +333,9 @@ int dbox_mailbox_create(struct mailbox *box, if (ret < 0) return -1; if (ret == 0) { - mail_storage_set_critical(&storage->storage, - "Mailbox %s has existing files in alt path, " - "rebuilding storage to avoid losing messages", - box->vname); + mailbox_set_critical(box, + "Existing files in alt path, " + "rebuilding storage to avoid losing messages"); storage->v.set_mailbox_corrupted(box); return -1; } diff --git a/src/lib-storage/index/dbox-multi/mdbox-mail.c b/src/lib-storage/index/dbox-multi/mdbox-mail.c index 1a13b41f85..f93d0a756c 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-mail.c +++ b/src/lib-storage/index/dbox-multi/mdbox-mail.c @@ -26,9 +26,8 @@ int mdbox_mail_lookup(struct mdbox_mailbox *mbox, struct mail_index_view *view, dbox_rec = data; if (dbox_rec == NULL || dbox_rec->map_uid == 0) { mail_index_lookup_uid(view, seq, &uid); - mail_storage_set_critical(&mbox->storage->storage.storage, - "mdbox %s: map uid lost for uid %u", - mailbox_get_path(&mbox->box), uid); + mailbox_set_critical(&mbox->box, + "mdbox: map uid lost for uid %u", uid); mdbox_storage_set_corrupted(mbox->storage); return -1; } @@ -43,10 +42,9 @@ int mdbox_mail_lookup(struct mdbox_mailbox *mbox, struct mail_index_view *view, cur_map_uid_validity = mdbox_map_get_uid_validity(mbox->storage->map); if (cur_map_uid_validity != mbox->map_uid_validity) { - mail_storage_set_critical(&mbox->storage->storage.storage, - "mdbox %s: map uidvalidity mismatch (%u vs %u)", - mailbox_get_path(&mbox->box), mbox->map_uid_validity, - cur_map_uid_validity); + mailbox_set_critical(&mbox->box, + "mdbox: map uidvalidity mismatch (%u vs %u)", + mbox->map_uid_validity, cur_map_uid_validity); mdbox_storage_set_corrupted(mbox->storage); return -1; } diff --git a/src/lib-storage/index/dbox-multi/mdbox-save.c b/src/lib-storage/index/dbox-multi/mdbox-save.c index f5ba869941..aa9a665d82 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-save.c +++ b/src/lib-storage/index/dbox-multi/mdbox-save.c @@ -394,7 +394,7 @@ void mdbox_transaction_save_commit_post(struct mail_save_context *_ctx, const char *box_path = mailbox_get_path(&ctx->mbox->box); if (fdatasync_path(box_path) < 0) { - mail_storage_set_critical(storage, + mail_set_critical(_ctx->dest_mail, "fdatasync_path(%s) failed: %m", box_path); } } diff --git a/src/lib-storage/index/dbox-multi/mdbox-storage.c b/src/lib-storage/index/dbox-multi/mdbox-storage.c index c1826bb386..b0951ae205 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-storage.c +++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c @@ -211,9 +211,9 @@ int mdbox_read_header(struct mdbox_mailbox *mbox, &data, &data_size); if (data_size < MDBOX_INDEX_HEADER_MIN_SIZE && (!mbox->creating || data_size != 0)) { - mail_storage_set_critical(&mbox->storage->storage.storage, - "mdbox %s: Invalid dbox header size: %"PRIuSIZE_T, - mailbox_get_path(&mbox->box), data_size); + mailbox_set_critical(&mbox->box, + "mdbox: Invalid dbox header size: %"PRIuSIZE_T, + data_size); mdbox_storage_set_corrupted(mbox->storage); return -1; } diff --git a/src/lib-storage/index/dbox-multi/mdbox-sync.c b/src/lib-storage/index/dbox-multi/mdbox-sync.c index 27ceb0add2..aaaa4e9f9b 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-sync.c +++ b/src/lib-storage/index/dbox-multi/mdbox-sync.c @@ -38,10 +38,9 @@ dbox_sync_verify_expunge_guid(struct mdbox_sync_context *ctx, uint32_t seq, memcmp(data, guid_128, GUID_128_SIZE) == 0) return 0; - mail_storage_set_critical(&ctx->mbox->storage->storage.storage, - "Mailbox %s: Expunged GUID mismatch for UID %u: %s vs %s", - ctx->mbox->box.vname, uid, - guid_128_to_string(data), guid_128_to_string(guid_128)); + mailbox_set_critical(&ctx->mbox->box, + "Expunged GUID mismatch for UID %u: %s vs %s", + uid, guid_128_to_string(data), guid_128_to_string(guid_128)); mdbox_storage_set_corrupted(ctx->mbox->storage); return -1; } @@ -145,9 +144,7 @@ static int mdbox_sync_index(struct mdbox_sync_context *ctx) return -1; return 1; } - mail_storage_set_critical(box->storage, - "Mailbox %s: Broken index: missing UIDVALIDITY", - box->vname); + mailbox_set_critical(box, "Broken index: missing UIDVALIDITY"); return 0; } @@ -225,7 +222,6 @@ int mdbox_sync_begin(struct mdbox_mailbox *mbox, enum mdbox_sync_flags flags, struct mdbox_map_atomic_context *atomic, struct mdbox_sync_context **ctx_r) { - struct mail_storage *storage = mbox->box.storage; const struct mail_index_header *hdr = mail_index_get_header(mbox->box.view); struct mdbox_sync_context *ctx; @@ -283,9 +279,8 @@ int mdbox_sync_begin(struct mdbox_mailbox *mbox, enum mdbox_sync_flags flags, /* corrupted */ if (storage_rebuilt) { - mail_storage_set_critical(storage, - "mdbox %s: Storage keeps breaking", - mailbox_get_path(&mbox->box)); + mailbox_set_critical(&mbox->box, + "mdbox: Storage keeps breaking"); return -1; } @@ -293,9 +288,8 @@ int mdbox_sync_begin(struct mdbox_mailbox *mbox, enum mdbox_sync_flags flags, try again from the beginning. */ mdbox_storage_set_corrupted(mbox->storage); if ((flags & MDBOX_SYNC_FLAG_NO_REBUILD) != 0) { - mail_storage_set_critical(storage, - "mdbox %s: Can't rebuild storage", - mailbox_get_path(&mbox->box)); + mailbox_set_critical(&mbox->box, + "mdbox: Can't rebuild storage"); return -1; } return mdbox_sync_begin(mbox, flags, atomic, ctx_r); diff --git a/src/lib-storage/index/dbox-single/sdbox-copy.c b/src/lib-storage/index/dbox-single/sdbox-copy.c index f21358ed39..3210c09500 100644 --- a/src/lib-storage/index/dbox-single/sdbox-copy.c +++ b/src/lib-storage/index/dbox-single/sdbox-copy.c @@ -45,7 +45,7 @@ sdbox_file_copy_attachments(struct sdbox_file *src_file, pool = pool_alloconly_create("sdbox attachments copy", 1024); p_array_init(&extrefs, pool, 16); if (!index_attachment_parse_extrefs(extrefs_line, pool, &extrefs)) { - mail_storage_set_critical(&dest_storage->storage, + mailbox_set_critical(&dest_file->mbox->box, "Can't copy %s with corrupted extref metadata: %s", src_file->file.cur_path, extrefs_line); pool_unref(&pool); @@ -75,7 +75,7 @@ sdbox_file_copy_attachments(struct sdbox_file *src_file, dest_fsfile = fs_file_init(dest_storage->attachment_fs, dest, FS_OPEN_MODE_READONLY); if (fs_copy(src_fsfile, dest_fsfile) < 0) { - mail_storage_set_critical(&dest_storage->storage, "%s", + mailbox_set_critical(&dest_file->mbox->box, "%s", fs_last_error(dest_storage->attachment_fs)); ret = -1; } else { @@ -131,9 +131,8 @@ sdbox_copy_hardlink(struct mail_save_context *_ctx, struct mail *mail) stream open) */ ret = 0; } else { - mail_storage_set_critical( - _ctx->transaction->box->storage, - "link(%s, %s) failed: %m", src_path, dest_path); + mail_set_critical(mail, "link(%s, %s) failed: %m", + src_path, dest_path); } dbox_file_unref(&src_file); dbox_file_unref(&dest_file); diff --git a/src/lib-storage/index/dbox-single/sdbox-file.c b/src/lib-storage/index/dbox-single/sdbox-file.c index 1256e12f73..48754a10e2 100644 --- a/src/lib-storage/index/dbox-single/sdbox-file.c +++ b/src/lib-storage/index/dbox-single/sdbox-file.c @@ -109,7 +109,7 @@ sdbox_file_attachment_relpath(struct sdbox_file *file, const char *srcpath) p = strchr(srcpath, '-'); if (p == NULL) { - mail_storage_set_critical(file->mbox->box.storage, + mailbox_set_critical(&file->mbox->box, "sdbox attachment path in invalid format: %s", srcpath); } else { p = strchr(p+1, '-'); @@ -136,7 +136,7 @@ static int sdbox_file_rename_attachments(struct sdbox_file *file) dest_file = fs_file_init(storage->attachment_fs, dest, FS_OPEN_MODE_READONLY); if (fs_rename(src_file, dest_file) < 0) { - mail_storage_set_critical(&storage->storage, "%s", + mailbox_set_critical(&file->mbox->box, "%s", fs_last_error(storage->attachment_fs)); ret = -1; } @@ -164,15 +164,15 @@ int sdbox_file_assign_uid(struct sdbox_file *file, uint32_t uid, new_path = t_strdup_printf("%s/%s", dir, new_fname); if (!ignore_if_exists && stat(new_path, &st) == 0) { - mail_storage_set_critical(&file->file.storage->storage, + mailbox_set_critical(&file->mbox->box, "sdbox: %s already exists, rebuilding index", new_path); sdbox_set_mailbox_corrupted(&file->mbox->box); return -1; } if (rename(old_path, new_path) < 0) { - mail_storage_set_critical(&file->file.storage->storage, - "rename(%s, %s) failed: %m", - old_path, new_path); + mailbox_set_critical(&file->mbox->box, + "rename(%s, %s) failed: %m", + old_path, new_path); return -1; } sdbox_file_init_paths(file, new_fname); @@ -203,8 +203,8 @@ static int sdbox_file_unlink_aborted_save_attachments(struct sdbox_file *file) fs_file = fs_file_init(fs, path, FS_OPEN_MODE_READONLY); if (fs_delete(fs_file) < 0 && errno != ENOENT) { - mail_storage_set_critical(&storage->storage, "%s", - fs_last_error(fs)); + mailbox_set_critical(&file->mbox->box, "%s", + fs_last_error(fs)); ret = -1; } fs_file_deinit(&fs_file); @@ -214,8 +214,8 @@ static int sdbox_file_unlink_aborted_save_attachments(struct sdbox_file *file) fs_file = fs_file_init(fs, path, FS_OPEN_MODE_READONLY); if (fs_delete(fs_file) < 0 && errno != ENOENT) { - mail_storage_set_critical(&storage->storage, "%s", - fs_last_error(fs)); + mailbox_set_critical(&file->mbox->box, "%s", + fs_last_error(fs)); ret = -1; } fs_file_deinit(&fs_file); @@ -228,7 +228,7 @@ int sdbox_file_unlink_aborted_save(struct sdbox_file *file) int ret = 0; if (unlink(file->file.cur_path) < 0) { - mail_storage_set_critical(file->mbox->box.storage, + mailbox_set_critical(&file->mbox->box, "unlink(%s) failed: %m", file->file.cur_path); ret = -1; } @@ -258,7 +258,7 @@ int sdbox_file_create_fd(struct dbox_file *file, const char *path, bool parents) perm->file_create_gid, perm->file_create_gid_origin) < 0 && errno != EEXIST) { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "mkdir_parents(%s) failed: %m", dir); return -1; } @@ -268,18 +268,17 @@ int sdbox_file_create_fd(struct dbox_file *file, const char *path, bool parents) umask(old_mask); } if (fd == -1) { - mail_storage_set_critical(box->storage, - "open(%s, O_CREAT) failed: %m", path); + mailbox_set_critical(box, "open(%s, O_CREAT) failed: %m", path); } else if (perm->file_create_gid == (gid_t)-1) { /* no group change */ } else if (fchown(fd, (uid_t)-1, perm->file_create_gid) < 0) { if (errno == EPERM) { - mail_storage_set_critical(box->storage, "%s", + mailbox_set_critical(box, "%s", eperm_error_get_chgrp("fchown", path, perm->file_create_gid, perm->file_create_gid_origin)); } else { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "fchown(%s, -1, %ld) failed: %m", path, (long)perm->file_create_gid); } diff --git a/src/lib-storage/index/dbox-single/sdbox-mail.c b/src/lib-storage/index/dbox-single/sdbox-mail.c index 7702d80ff7..62cac9ef16 100644 --- a/src/lib-storage/index/dbox-single/sdbox-mail.c +++ b/src/lib-storage/index/dbox-single/sdbox-mail.c @@ -21,9 +21,7 @@ static void sdbox_mail_set_expunged(struct dbox_mail *mail) return; } - mail_storage_set_critical(_mail->box->storage, - "dbox %s: Unexpectedly lost uid=%u", - mailbox_get_path(_mail->box), _mail->uid); + mail_set_critical(_mail, "dbox: Unexpectedly lost uid"); sdbox_set_mailbox_corrupted(_mail->box); } @@ -50,9 +48,8 @@ static int sdbox_mail_file_set(struct dbox_mail *mail) /* it doesn't have input stream yet */ ret = dbox_file_open(mail->open_file, &deleted); if (ret <= 0) { - mail_storage_set_critical(_mail->box->storage, - "dbox %s: Unexpectedly lost mail being saved", - mailbox_get_path(_mail->box)); + mail_set_critical(_mail, + "dbox: Unexpectedly lost mail being saved"); sdbox_set_mailbox_corrupted(_mail->box); return -1; } diff --git a/src/lib-storage/index/dbox-single/sdbox-save.c b/src/lib-storage/index/dbox-single/sdbox-save.c index 4a3333650b..03cd3a4e29 100644 --- a/src/lib-storage/index/dbox-single/sdbox-save.c +++ b/src/lib-storage/index/dbox-single/sdbox-save.c @@ -364,7 +364,7 @@ void sdbox_transaction_save_commit_post(struct mail_save_context *_ctx, const char *box_path = mailbox_get_path(&ctx->mbox->box); if (fdatasync_path(box_path) < 0) { - mail_storage_set_critical(storage, + mail_set_critical(_ctx->dest_mail, "fdatasync_path(%s) failed: %m", box_path); } } diff --git a/src/lib-storage/index/dbox-single/sdbox-storage.c b/src/lib-storage/index/dbox-single/sdbox-storage.c index 57f43a9aab..f49f5acf64 100644 --- a/src/lib-storage/index/dbox-single/sdbox-storage.c +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c @@ -155,10 +155,8 @@ int sdbox_read_header(struct sdbox_mailbox *mbox, if (data_size < SDBOX_INDEX_HEADER_MIN_SIZE && (!mbox->box.creating || data_size != 0)) { if (log_error) { - mail_storage_set_critical( - &mbox->storage->storage.storage, - "sdbox %s: Invalid dbox header size", - mailbox_get_path(&mbox->box)); + mailbox_set_critical(&mbox->box, + "sdbox: Invalid dbox header size"); } ret = -1; } else { @@ -391,9 +389,8 @@ sdbox_mailbox_create(struct mailbox *box, /* another process just created the mailbox. read the mailbox_guid. */ if (sdbox_read_header(mbox, &hdr, FALSE, &need_resize) < 0) { - mail_storage_set_critical(box->storage, - "sdbox %s: Failed to read newly created dbox header", - mailbox_get_path(&mbox->box)); + mailbox_set_critical(box, + "sdbox: Failed to read newly created dbox header"); return -1; } memcpy(mbox->mailbox_guid, hdr.mailbox_guid, diff --git a/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c b/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c index 317253136c..e773f3aa70 100644 --- a/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c +++ b/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c @@ -95,7 +95,6 @@ sdbox_sync_add_file(struct index_rebuild_context *ctx, static int sdbox_sync_index_rebuild_dir(struct index_rebuild_context *ctx, const char *path, bool primary) { - struct mail_storage *storage = ctx->box->storage; DIR *dir; struct dirent *d; int ret = 0; @@ -109,8 +108,7 @@ static int sdbox_sync_index_rebuild_dir(struct index_rebuild_context *ctx, } return index_mailbox_fix_inconsistent_existence(ctx->box, path); } - mail_storage_set_critical(storage, - "opendir(%s) failed: %m", path); + mailbox_set_critical(ctx->box, "opendir(%s) failed: %m", path); return -1; } do { @@ -121,14 +119,12 @@ static int sdbox_sync_index_rebuild_dir(struct index_rebuild_context *ctx, ret = sdbox_sync_add_file(ctx, d->d_name, primary); } while (ret >= 0); if (errno != 0) { - mail_storage_set_critical(storage, - "readdir(%s) failed: %m", path); + mailbox_set_critical(ctx->box, "readdir(%s) failed: %m", path); ret = -1; } if (closedir(dir) < 0) { - mail_storage_set_critical(storage, - "closedir(%s) failed: %m", path); + mailbox_set_critical(ctx->box, "closedir(%s) failed: %m", path); ret = -1; } return ret; @@ -164,13 +160,11 @@ sdbox_sync_index_rebuild_singles(struct index_rebuild_context *ctx) sdbox_sync_set_uidvalidity(ctx); if (sdbox_sync_index_rebuild_dir(ctx, path, TRUE) < 0) { - mail_storage_set_critical(ctx->box->storage, - "sdbox: Rebuilding failed on path %s", - mailbox_get_path(ctx->box)); + mailbox_set_critical(ctx->box, "sdbox: Rebuilding failed"); ret = -1; } else if (alt_path != NULL) { if (sdbox_sync_index_rebuild_dir(ctx, alt_path, FALSE) < 0) { - mail_storage_set_critical(ctx->box->storage, + mailbox_set_critical(ctx->box, "sdbox: Rebuilding failed on alt path %s", alt_path); ret = -1; @@ -199,9 +193,9 @@ int sdbox_sync_index_rebuild(struct sdbox_mailbox *mbox, bool force) i_warning("sdbox %s: Rebuilding index", mailbox_get_path(&mbox->box)); if (dbox_verify_alt_storage(mbox->box.list) < 0) { - mail_storage_set_critical(mbox->box.storage, - "sdbox %s: Alt storage not mounted, " - "aborting index rebuild", mailbox_get_path(&mbox->box)); + mailbox_set_critical(&mbox->box, + "sdbox: Alt storage not mounted, " + "aborting index rebuild"); return -1; } diff --git a/src/lib-storage/index/dbox-single/sdbox-sync.c b/src/lib-storage/index/dbox-single/sdbox-sync.c index ba6f9d2c70..7ded78da6d 100644 --- a/src/lib-storage/index/dbox-single/sdbox-sync.c +++ b/src/lib-storage/index/dbox-single/sdbox-sync.c @@ -116,9 +116,8 @@ static int sdbox_sync_index(struct sdbox_sync_context *ctx) return -1; return 1; } - mail_storage_set_critical(box->storage, - "sdbox %s: Broken index: missing UIDVALIDITY", - mailbox_get_path(box)); + mailbox_set_critical(box, + "sdbox: Broken index: missing UIDVALIDITY"); sdbox_set_mailbox_corrupted(box); return 0; } @@ -191,7 +190,6 @@ sdbox_refresh_header(struct sdbox_mailbox *mbox, bool retry, bool log_error) int sdbox_sync_begin(struct sdbox_mailbox *mbox, enum sdbox_sync_flags flags, struct sdbox_sync_context **ctx_r) { - struct mail_storage *storage = mbox->box.storage; const struct mail_index_header *hdr = mail_index_get_header(mbox->box.view); struct sdbox_sync_context *ctx; @@ -243,9 +241,8 @@ int sdbox_sync_begin(struct sdbox_mailbox *mbox, enum sdbox_sync_flags flags, rebuild. */ if (ret == 0) { if (i >= SDBOX_REBUILD_COUNT) { - mail_storage_set_critical(storage, - "sdbox %s: Index keeps breaking", - mailbox_get_path(&ctx->mbox->box)); + mailbox_set_critical(&ctx->mbox->box, + "sdbox: Index keeps breaking"); ret = -1; } else { /* do a full resync and try again. */ diff --git a/src/lib-storage/index/imapc/imapc-mail-fetch.c b/src/lib-storage/index/imapc/imapc-mail-fetch.c index cfb11fdc42..e6c1c9f368 100644 --- a/src/lib-storage/index/imapc/imapc-mail-fetch.c +++ b/src/lib-storage/index/imapc/imapc-mail-fetch.c @@ -92,7 +92,7 @@ imapc_mail_fetch_callback(const struct imapc_command_reply *reply, /* The disconnection message was already logged */ mail_storage_set_internal_error(&mbox->storage->storage); } else { - mail_storage_set_critical(&mbox->storage->storage, + mailbox_set_critical(&mbox->box, "imapc: Mail FETCH failed: %s", reply->text_full); } imapc_client_stop(mbox->storage->client->client); @@ -765,14 +765,14 @@ imapc_args_to_bodystructure(struct imapc_mail *mail, pool_t pool; if (!imap_arg_get_list(list_arg, &args)) { - mail_storage_set_critical(mail->imail.mail.mail.box->storage, + mail_set_critical(&mail->imail.mail.mail, "imapc: Server sent invalid BODYSTRUCTURE parameters"); return NULL; } pool = pool_alloconly_create("imap bodystructure", 1024); if (imap_bodystructure_parse_args(args, pool, &parts, &error) < 0) { - mail_storage_set_critical(mail->imail.mail.mail.box->storage, + mail_set_critical(&mail->imail.mail.mail, "imapc: Server sent invalid BODYSTRUCTURE: %s", error); ret = NULL; } else { diff --git a/src/lib-storage/index/imapc/imapc-mail.c b/src/lib-storage/index/imapc/imapc-mail.c index 87645dd64b..2b9146b705 100644 --- a/src/lib-storage/index/imapc/imapc-mail.c +++ b/src/lib-storage/index/imapc/imapc-mail.c @@ -87,10 +87,9 @@ static int imapc_mail_failed(struct mail *mail, const char *field) mailbox. This seems to be fixed in newer versions. */ fix_broken_mail = imail->fetch_ignore_if_missing; - mail_storage_set_critical(mail->box->storage, - "imapc: Remote server didn't send %s for UID %u in %s%s (FETCH replied: %s)", - field, mail->uid, mail->box->vname, - fix_broken_mail ? " - treating it as empty" : "", + mail_set_critical(mail, + "imapc: Remote server didn't send %s%s (FETCH replied: %s)", + field, fix_broken_mail ? " - treating it as empty" : "", imail->last_fetch_reply); } return fix_broken_mail ? 0 : -1; @@ -194,9 +193,8 @@ static int imapc_mail_get_physical_size(struct mail *_mail, uoff_t *size_r) &data->physical_size); if (ret <= 0) { i_assert(ret != 0); - mail_storage_set_critical(_mail->box->storage, - "imapc: stat(%s) failed: %m", - i_stream_get_name(data->stream)); + mail_set_critical(_mail, "imapc: stat(%s) failed: %m", + i_stream_get_name(data->stream)); return -1; } *size_r = data->physical_size; @@ -566,7 +564,7 @@ imapc_mail_get_special(struct mail *_mail, enum mail_fetch_field field, if (imapc_mail_get_guid(_mail, value_r) < 0) return -1; if (str_to_uint64(*value_r, &num) < 0) { - mail_storage_set_critical(_mail->box->storage, + mail_set_critical(_mail, "X-GM-MSGID not 64bit integer as expected for POP3 UIDL generation: %s", *value_r); return -1; } diff --git a/src/lib-storage/index/imapc/imapc-save.c b/src/lib-storage/index/imapc/imapc-save.c index 59e8dd66ab..1633cea310 100644 --- a/src/lib-storage/index/imapc/imapc-save.c +++ b/src/lib-storage/index/imapc/imapc-save.c @@ -63,7 +63,6 @@ imapc_save_alloc(struct mailbox_transaction_context *t) int imapc_save_begin(struct mail_save_context *_ctx, struct istream *input) { struct imapc_save_context *ctx = IMAPC_SAVECTX(_ctx); - struct mail_storage *storage = _ctx->transaction->box->storage; const char *path; i_assert(ctx->fd == -1); @@ -74,8 +73,8 @@ int imapc_save_begin(struct mail_save_context *_ctx, struct istream *input) ctx->fd = imapc_client_create_temp_fd(ctx->mbox->storage->client->client, &path); if (ctx->fd == -1) { - mail_storage_set_critical(storage, - "Couldn't create temp file %s", path); + mail_set_critical(_ctx->dest_mail, + "Couldn't create temp file %s", path); ctx->failed = TRUE; return -1; } @@ -177,7 +176,7 @@ static void imapc_save_callback(const struct imapc_command_reply *reply, MAIL_ERROR_PARAMS, reply); ctx->ret = -1; } else { - mail_storage_set_critical(&ctx->ctx->mbox->storage->storage, + mailbox_set_critical(&ctx->ctx->mbox->box, "imapc: APPEND failed: %s", reply->text_full); ctx->ret = -1; } @@ -276,7 +275,7 @@ int imapc_save_finish(struct mail_save_context *_ctx) if (!ctx->failed) { if (o_stream_finish(_ctx->data.output) < 0) { if (!mail_storage_set_error_from_errno(storage)) { - mail_storage_set_critical(storage, + mail_set_critical(_ctx->dest_mail, "write(%s) failed: %s", ctx->temp_path, o_stream_get_error(_ctx->data.output)); } @@ -392,7 +391,7 @@ static void imapc_copy_callback(const struct imapc_command_reply *reply, MAIL_ERROR_PARAMS, reply); ctx->ret = -1; } else { - mail_storage_set_critical(&ctx->ctx->mbox->storage->storage, + mailbox_set_critical(&ctx->ctx->mbox->box, "imapc: COPY failed: %s", reply->text_full); ctx->ret = -1; } diff --git a/src/lib-storage/index/imapc/imapc-search.c b/src/lib-storage/index/imapc/imapc-search.c index 13b223edb3..57427f68f9 100644 --- a/src/lib-storage/index/imapc/imapc-search.c +++ b/src/lib-storage/index/imapc/imapc-search.c @@ -193,7 +193,7 @@ static void imapc_search_callback(const struct imapc_command_reply *reply, } else if (reply->state == IMAPC_COMMAND_STATE_DISCONNECTED) { mail_storage_set_internal_error(mbox->box.storage); } else { - mail_storage_set_critical(mbox->box.storage, + mailbox_set_critical(&mbox->box, "imapc: Command failed: %s", reply->text_full); } imapc_client_stop(mbox->storage->client->client); diff --git a/src/lib-storage/index/imapc/imapc-storage.c b/src/lib-storage/index/imapc/imapc-storage.c index 6979d82e79..080f73eaaa 100644 --- a/src/lib-storage/index/imapc/imapc-storage.c +++ b/src/lib-storage/index/imapc/imapc-storage.c @@ -640,9 +640,8 @@ imapc_mailbox_open_callback(const struct imapc_command_reply *reply, ctx->mbox->selected = TRUE; if (reply->state == IMAPC_COMMAND_STATE_OK) { if (!imapc_mailbox_verify_select(ctx->mbox, &error)) { - mail_storage_set_critical(ctx->mbox->box.storage, - "imapc: Opening mailbox '%s' failed: %s", - ctx->mbox->box.name, error); + mailbox_set_critical(&ctx->mbox->box, + "imapc: Opening mailbox failed: %s", error); ctx->ret = -1; } else { ctx->ret = 0; @@ -657,9 +656,8 @@ imapc_mailbox_open_callback(const struct imapc_command_reply *reply, ctx->ret = -1; mail_storage_set_internal_error(ctx->mbox->box.storage); } else { - mail_storage_set_critical(ctx->mbox->box.storage, - "imapc: Opening mailbox '%s' failed: %s", - ctx->mbox->box.name, reply->text_full); + mailbox_set_critical(&ctx->mbox->box, + "imapc: Opening mailbox failed: %s", reply->text_full); ctx->ret = -1; } imapc_client_stop(ctx->mbox->storage->client->client); diff --git a/src/lib-storage/index/imapc/imapc-sync.c b/src/lib-storage/index/imapc/imapc-sync.c index 4cda5e0552..0ef3f14c9a 100644 --- a/src/lib-storage/index/imapc/imapc-sync.c +++ b/src/lib-storage/index/imapc/imapc-sync.c @@ -39,9 +39,9 @@ static void imapc_sync_callback(const struct imapc_command_reply *reply, mail_storage_set_internal_error(&ctx->mbox->storage->storage); ctx->failed = TRUE; } else { - mail_storage_set_critical(&ctx->mbox->storage->storage, - "imapc: Sync command '%s' failed: %s", - cmd->cmd_str, reply->text_full); + mailbox_set_critical(&ctx->mbox->box, + "imapc: Sync command '%s' failed: %s", + cmd->cmd_str, reply->text_full); ctx->failed = TRUE; } @@ -604,7 +604,7 @@ static int imapc_sync_finish(struct imapc_sync_context **_ctx) mail_index_sync_rollback(&ctx->index_sync_ctx); } if (ctx->mbox->sync_gmail_pop3_search_tag != NULL) { - mail_storage_set_critical(&ctx->mbox->storage->storage, + mailbox_set_critical(&ctx->mbox->box, "gmail-pop3 search not successful"); i_free_and_null(ctx->mbox->sync_gmail_pop3_search_tag); ret = -1; diff --git a/src/lib-storage/index/index-attachment.c b/src/lib-storage/index/index-attachment.c index 2ed6da8af6..d54dcefcef 100644 --- a/src/lib-storage/index/index-attachment.c +++ b/src/lib-storage/index/index-attachment.c @@ -69,12 +69,12 @@ static int index_attachment_open_temp_fd(void *context) mail_user_set_get_temp_prefix(temp_path, storage->user->set); fd = safe_mkstemp_hostpid(temp_path, 0600, (uid_t)-1, (gid_t)-1); if (fd == -1) { - mail_storage_set_critical(storage, + mailbox_set_critical(ctx->transaction->box, "safe_mkstemp(%s) failed: %m", str_c(temp_path)); return -1; } if (unlink(str_c(temp_path)) < 0) { - mail_storage_set_critical(storage, + mailbox_set_critical(ctx->transaction->box, "unlink(%s) failed: %m", str_c(temp_path)); i_close_fd(&fd); return -1; @@ -199,7 +199,7 @@ static int save_check_write_error(struct mail_save_context *ctx, return 0; if (!mail_storage_set_error_from_errno(storage)) { - mail_storage_set_critical(storage, "write(%s) failed: %s", + mail_set_critical(ctx->dest_mail, "write(%s) failed: %s", o_stream_get_name(output), o_stream_get_error(output)); } return -1; @@ -207,7 +207,6 @@ static int save_check_write_error(struct mail_save_context *ctx, int index_attachment_save_continue(struct mail_save_context *ctx) { - struct mail_storage *storage = ctx->transaction->box->storage; struct mail_save_attachment *attach = ctx->data.attach; const unsigned char *data; size_t size; @@ -231,7 +230,7 @@ int index_attachment_save_continue(struct mail_save_context *ctx) } while (ret != -1); if (attach->input->stream_errno != 0) { - mail_storage_set_critical(storage, "read(%s) failed: %s", + mail_set_critical(ctx->dest_mail, "read(%s) failed: %s", i_stream_get_name(attach->input), i_stream_get_error(attach->input)); return -1; diff --git a/src/lib-storage/index/index-attribute.c b/src/lib-storage/index/index-attribute.c index 6168f8da52..ae92ebe97b 100644 --- a/src/lib-storage/index/index-attribute.c +++ b/src/lib-storage/index/index-attribute.c @@ -240,7 +240,7 @@ int index_storage_attribute_get(struct mailbox *box, key_get_prefixed(type, mailbox_prefix, key), &value_r->value, &error); if (ret < 0) { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "Failed to set attribute %s: %s", key, error); return -1; } @@ -298,7 +298,7 @@ int index_storage_attribute_iter_deinit(struct mailbox_attribute_iter *_iter) ret = iter->dict_disabled ? 0 : -1; } else { if ((ret = dict_iterate_deinit(&iter->diter, &error)) < 0) { - mail_storage_set_critical(_iter->box->storage, + mailbox_set_critical(_iter->box, "dict_iterate(%s) failed: %s", iter->prefix, error); } diff --git a/src/lib-storage/index/index-mail-binary.c b/src/lib-storage/index/index-mail-binary.c index 32df0670cb..b16a80aac6 100644 --- a/src/lib-storage/index/index-mail-binary.c +++ b/src/lib-storage/index/index-mail-binary.c @@ -114,7 +114,7 @@ add_binary_part(struct binary_ctx *ctx, const struct message_part *part, message_parse_header_deinit(&parser); if (ctx->input->stream_errno != 0) { - mail_storage_set_critical(ctx->mail->box->storage, + mail_set_critical(ctx->mail, "read(%s) failed: %s", i_stream_get_name(ctx->input), i_stream_get_error(ctx->input)); return -1; @@ -399,10 +399,9 @@ index_mail_read_binary_to_cache(struct mail *_mail, MAIL_ERROR_INVALIDDATA, "Invalid data in MIME part"); } else { - mail_storage_set_critical(_mail->box->storage, - "read(%s) failed: %s", - i_stream_get_name(is), - i_stream_get_error(is)); + mail_set_critical(_mail, "read(%s) failed: %s", + i_stream_get_name(is), + i_stream_get_error(is)); } i_stream_unref(&is); binary_streams_free(&ctx); diff --git a/src/lib-storage/index/index-mail.c b/src/lib-storage/index/index-mail.c index d01b65dfc1..e6f73b12cf 100644 --- a/src/lib-storage/index/index-mail.c +++ b/src/lib-storage/index/index-mail.c @@ -1148,10 +1148,9 @@ void index_mail_stream_log_failure_for(struct index_mail *mail, if (_mail->expunged) return; } - mail_storage_set_critical(_mail->box->storage, - "read(%s) failed: %s (uid=%u, box=%s, read reason=%s)", + mail_set_critical(_mail, + "read(%s) failed: %s (read reason=%s)", i_stream_get_name(input), i_stream_get_error(input), - _mail->uid, mailbox_get_vname(_mail->box), mail->mail.get_stream_reason == NULL ? "" : mail->mail.get_stream_reason); } @@ -2339,9 +2338,9 @@ void index_mail_set_cache_corrupted(struct mail *mail, imail->data.forced_no_caching = TRUE; if (mail->saving) { - mail_storage_set_critical(mail->box->storage, - "BUG: Broken %s found in mailbox %s while saving a new mail: %s", - field_name, mail->box->vname, reason); + mail_set_critical(mail, + "BUG: Broken %s found while saving a new mail: %s", + field_name, reason); } else if (reason[0] == '\0') { mail_set_mail_cache_corrupted(mail, "Broken %s in mailbox %s", diff --git a/src/lib-storage/index/index-mailbox-size.c b/src/lib-storage/index/index-mailbox-size.c index 37f03da6d3..40806f9b9a 100644 --- a/src/lib-storage/index/index-mailbox-size.c +++ b/src/lib-storage/index/index-mailbox-size.c @@ -71,7 +71,7 @@ static void vsize_header_refresh(struct mailbox_vsize_update *update) memcpy(&update->vsize_hdr, data, sizeof(update->vsize_hdr)); else { if (size != 0) { - mail_storage_set_critical(update->box->storage, + mailbox_set_critical(update->box, "vsize-hdr has invalid size: %"PRIuSIZE_T, size); } @@ -94,7 +94,7 @@ index_mailbox_vsize_check_rebuild(struct mailbox_vsize_update *update) if (update->vsize_hdr.message_count != seq2) { if (update->vsize_hdr.message_count < seq2) { - mail_storage_set_critical(update->box->storage, + mailbox_set_critical(update->box, "vsize-hdr has invalid message-count (%u < %u)", update->vsize_hdr.message_count, seq2); } else { @@ -139,7 +139,7 @@ static bool vsize_update_lock_full(struct mailbox_vsize_update *update, /* don't log lock timeouts, because we're somewhat expecting them. Especially when lock_secs is 0. */ if (ret < 0) - mail_storage_set_critical(box->storage, "%s", error); + mailbox_set_critical(box, "%s", error); update->lock_failed = TRUE; return FALSE; } @@ -197,7 +197,7 @@ static void index_mailbox_vsize_notify_indexer(struct mailbox *box) "/"INDEXER_SOCKET_NAME, NULL); fd = net_connect_unix(path); if (fd == -1) { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "Can't start vsize building on background: " "net_connect_unix(%s) failed: %m", path); return; @@ -210,7 +210,7 @@ static void index_mailbox_vsize_notify_indexer(struct mailbox *box) str_append_c(str, '\n'); if (write_full(fd, str_data(str), str_len(str)) < 0) { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "Can't start vsize building on background: " "write(%s) failed: %m", path); } @@ -242,14 +242,14 @@ void index_mailbox_vsize_hdr_expunge(struct mailbox_vsize_update *update, if (uid > update->vsize_hdr.highest_uid) return; if (update->vsize_hdr.message_count == 0) { - mail_storage_set_critical(update->box->storage, + mailbox_set_critical(update->box, "vsize-hdr's message_count shrank below 0"); i_zero(&update->vsize_hdr); return; } update->vsize_hdr.message_count--; if (update->vsize_hdr.vsize < vsize) { - mail_storage_set_critical(update->box->storage, + mailbox_set_critical(update->box, "vsize-hdr's vsize shrank below 0"); i_zero(&update->vsize_hdr); return; diff --git a/src/lib-storage/index/index-search.c b/src/lib-storage/index/index-search.c index 36791fb050..96fae0da9b 100644 --- a/src/lib-storage/index/index-search.c +++ b/src/lib-storage/index/index-search.c @@ -703,7 +703,7 @@ static void search_body(struct mail_search_arg *arg, i_assert(ret >= 0 || ctx->input->stream_errno != 0); } if (ctx->input->stream_errno != 0) { - mail_storage_set_critical(ctx->index_ctx->box->storage, + mailbox_set_critical(ctx->index_ctx->box, "read(%s) failed: %s", i_stream_get_name(ctx->input), i_stream_get_error(ctx->input)); } @@ -788,7 +788,7 @@ static int search_arg_match_text(struct mail_search_arg *args, message_parse_header(input, NULL, hdr_parser_flags, search_header, &hdr_ctx); if (input->stream_errno != 0) { - mail_storage_set_critical(ctx->box->storage, + mailbox_set_critical(ctx->box, "read(%s) failed: %s", i_stream_get_name(input), i_stream_get_error(input)); diff --git a/src/lib-storage/index/index-sort-string.c b/src/lib-storage/index/index-sort-string.c index 8ebc0866e9..990ab235c4 100644 --- a/src/lib-storage/index/index-sort-string.c +++ b/src/lib-storage/index/index-sort-string.c @@ -838,9 +838,8 @@ static void index_sort_list_reset_broken(struct sort_string_context *ctx, struct mailbox *box = ctx->program->t->box; struct mail_sort_node *node; - mail_storage_set_critical(box->storage, - "%s: Broken %s indexes, resetting: %s", - box->name, ctx->primary_sort_name, reason); + mailbox_set_critical(box, "Broken %s indexes, resetting: %s", + ctx->primary_sort_name, reason); array_clear(&ctx->zero_nodes); array_append_array(&ctx->zero_nodes, diff --git a/src/lib-storage/index/index-storage.c b/src/lib-storage/index/index-storage.c index b10f0c3c29..2155538fba 100644 --- a/src/lib-storage/index/index-storage.c +++ b/src/lib-storage/index/index-storage.c @@ -218,8 +218,7 @@ int index_storage_mailbox_exists_full(struct mailbox *box, const char *subdir, return 0; } if (!ENOTFOUND(errno) && errno != EACCES) { - mail_storage_set_critical(box->storage, - "stat(%s) failed: %m", path); + mailbox_set_critical(box, "stat(%s) failed: %m", path); return -1; } @@ -316,7 +315,7 @@ int index_storage_mailbox_open(struct mailbox *box, bool move_to_memory) } if ((index_flags & MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY) != 0) { if (mail_index_is_in_memory(box->index)) { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "Couldn't create index file"); mail_index_close(box->index); return -1; @@ -1187,7 +1186,7 @@ int index_storage_save_continue(struct mail_save_context *ctx, break; case OSTREAM_SEND_ISTREAM_RESULT_ERROR_OUTPUT: if (!mail_storage_set_error_from_errno(storage)) { - mail_storage_set_critical(storage, + mail_set_critical(ctx->dest_mail, "save: write(%s) failed: %s", o_stream_get_name(ctx->data.output), o_stream_get_error(ctx->data.output)); @@ -1203,7 +1202,7 @@ int index_storage_save_continue(struct mail_save_context *ctx, } while (i_stream_read(input) > 0); if (input->stream_errno != 0) { - mail_storage_set_critical(storage, "save: read(%s) failed: %s", + mail_set_critical(ctx->dest_mail, "save: read(%s) failed: %s", i_stream_get_name(input), i_stream_get_error(input)); return -1; } @@ -1249,8 +1248,7 @@ int index_mailbox_fix_inconsistent_existence(struct mailbox *box, } else if (errno == ENOENT) { /* race condition - mailbox was just deleted */ } else { - mail_storage_set_critical(box->storage, - "stat(%s) failed: %m", index_path); + mailbox_set_critical(box, "stat(%s) failed: %m", index_path); return -1; } mailbox_set_deleted(box); diff --git a/src/lib-storage/index/index-sync-pvt.c b/src/lib-storage/index/index-sync-pvt.c index 530052ce85..6b9d407ddd 100644 --- a/src/lib-storage/index/index-sync-pvt.c +++ b/src/lib-storage/index/index-sync-pvt.c @@ -32,7 +32,7 @@ static int sync_pvt_expunges(struct index_mailbox_sync_pvt_context *ctx) mail_index_expunge(ctx->trans_pvt, seq_pvt); seq_pvt++; } else { - mail_storage_set_critical(ctx->box->storage, + mailbox_set_critical(ctx->box, "%s: Message UID=%u unexpectedly inserted to mailbox", ctx->box->index_pvt->filepath, uid_shared); return -1; diff --git a/src/lib-storage/index/index-sync.c b/src/lib-storage/index/index-sync.c index 5b029aad03..742909e7f6 100644 --- a/src/lib-storage/index/index-sync.c +++ b/src/lib-storage/index/index-sync.c @@ -280,9 +280,9 @@ void index_sync_update_recent_count(struct mailbox *box) hdr = mail_index_get_header(box->view); if (hdr->first_recent_uid < ibox->recent_flags_prev_first_recent_uid) { - mail_storage_set_critical(box->storage, - "Mailbox %s: first_recent_uid unexpectedly shrank: %u -> %u", - box->vname, ibox->recent_flags_prev_first_recent_uid, + mailbox_set_critical(box, + "first_recent_uid unexpectedly shrank: %u -> %u", + ibox->recent_flags_prev_first_recent_uid, hdr->first_recent_uid); mailbox_recent_flags_reset(box); } @@ -465,8 +465,7 @@ index_storage_list_index_has_changed_full(struct mailbox *box, if (stat(path, &st) < 0) { if (errno == ENOENT) return INDEX_STORAGE_LIST_CHANGE_NOT_IN_FS; - mail_storage_set_critical(box->storage, - "stat(%s) failed: %m", path); + mailbox_set_critical(box, "stat(%s) failed: %m", path); return INDEX_STORAGE_LIST_CHANGE_ERROR; } if (rec->size != (st.st_size & 0xffffffffU)) @@ -522,8 +521,7 @@ void index_storage_list_index_update_sync(struct mailbox *box, path = t_strconcat(dir, "/", box->index_prefix, ".log", NULL); if (stat(path, &st) < 0) { - mail_storage_set_critical(box->storage, - "stat(%s) failed: %m", path); + mailbox_set_critical(box, "stat(%s) failed: %m", path); return; } diff --git a/src/lib-storage/index/index-thread.c b/src/lib-storage/index/index-thread.c index 26733779e2..5e2baf4714 100644 --- a/src/lib-storage/index/index-thread.c +++ b/src/lib-storage/index/index-thread.c @@ -98,10 +98,9 @@ mail_strmap_rec_get_msgid(struct mail_thread_context *ctx, if (msgid == NULL) { /* shouldn't have happened, probably corrupted */ - mail_storage_set_critical(mail->box->storage, - "Corrupted thread index for mailbox %s: " - "UID %u lost Message ID %u", - mail->box->vname, mail->uid, rec->ref_index); + mail_set_critical(mail, + "Corrupted thread index: lost Message ID %u", + rec->ref_index); ctx->failed = TRUE; ctx->corrupted = TRUE; return -1; diff --git a/src/lib-storage/index/index-transaction.c b/src/lib-storage/index/index-transaction.c index 92b1796e92..d67bd1bb4c 100644 --- a/src/lib-storage/index/index-transaction.c +++ b/src/lib-storage/index/index-transaction.c @@ -37,14 +37,14 @@ index_transaction_index_commit(struct mail_index_transaction *index_trans, if (t->attr_pvt_trans != NULL) { if (dict_transaction_commit(&t->attr_pvt_trans, &error) < 0) { - mail_storage_set_critical(t->box->storage, + mailbox_set_critical(t->box, "Dict private transaction commit failed: %s", error); ret = -1; } } if (t->attr_shared_trans != NULL) { if (dict_transaction_commit(&t->attr_shared_trans, &error) < 0) { - mail_storage_set_critical(t->box->storage, + mailbox_set_critical(t->box, "Dict shared transaction commit failed: %s", error); ret = -1; } diff --git a/src/lib-storage/index/maildir/maildir-copy.c b/src/lib-storage/index/maildir/maildir-copy.c index 0cc0f35812..8b13844049 100644 --- a/src/lib-storage/index/maildir/maildir-copy.c +++ b/src/lib-storage/index/maildir/maildir-copy.c @@ -45,9 +45,8 @@ static int do_hardlink(struct maildir_mailbox *mbox, const char *path, if (errno == EACCES || ECANTLINK(errno) || errno == EEXIST) return 1; - mail_storage_set_critical(&mbox->storage->storage, - "link(%s, %s) failed: %m", - path, ctx->dest_path); + mailbox_set_critical(&mbox->box, "link(%s, %s) failed: %m", + path, ctx->dest_path); return -1; } diff --git a/src/lib-storage/index/maildir/maildir-keywords.c b/src/lib-storage/index/maildir/maildir-keywords.c index c8d7aa4119..6dbd09e321 100644 --- a/src/lib-storage/index/maildir/maildir-keywords.c +++ b/src/lib-storage/index/maildir/maildir-keywords.c @@ -132,8 +132,8 @@ static int maildir_keywords_sync(struct maildir_keywords *mk) mk->synced = TRUE; return 0; } - mail_storage_set_critical(mk->storage, - "stat(%s) failed: %m", mk->path); + mailbox_set_critical(&mk->mbox->box, + "stat(%s) failed: %m", mk->path); return -1; } @@ -151,8 +151,8 @@ static int maildir_keywords_sync(struct maildir_keywords *mk) mk->synced = TRUE; return 0; } - mail_storage_set_critical(mk->storage, - "open(%s) failed: %m", mk->path); + mailbox_set_critical(&mk->mbox->box, + "open(%s) failed: %m", mk->path); return -1; } @@ -184,8 +184,8 @@ static int maildir_keywords_sync(struct maildir_keywords *mk) i_stream_destroy(&input); if (close(fd) < 0) { - mail_storage_set_critical(mk->storage, - "close(%s) failed: %m", mk->path); + mailbox_set_critical(&mk->mbox->box, + "close(%s) failed: %m", mk->path); return -1; } @@ -302,14 +302,14 @@ static int maildir_keywords_write_fd(struct maildir_keywords *mk, str_printfa(str, "%u %s\n", i, keywords[i]); } if (write_full(fd, str_data(str), str_len(str)) < 0) { - mail_storage_set_critical(mk->storage, - "write_full(%s) failed: %m", path); + mailbox_set_critical(&mk->mbox->box, + "write_full(%s) failed: %m", path); return -1; } if (fstat(fd, &st) < 0) { - mail_storage_set_critical(mk->storage, - "fstat(%s) failed: %m", path); + mailbox_set_critical(&mk->mbox->box, + "fstat(%s) failed: %m", path); return -1; } @@ -317,12 +317,12 @@ static int maildir_keywords_write_fd(struct maildir_keywords *mk, perm->file_create_gid != (gid_t)-1) { if (fchown(fd, (uid_t)-1, perm->file_create_gid) < 0) { if (errno == EPERM) { - mail_storage_set_critical(mk->storage, "%s", + mailbox_set_critical(&mk->mbox->box, "%s", eperm_error_get_chgrp("fchown", path, perm->file_create_gid, perm->file_create_gid_origin)); } else { - mail_storage_set_critical(mk->storage, + mailbox_set_critical(&mk->mbox->box, "fchown(%s) failed: %m", path); } } @@ -337,14 +337,14 @@ static int maildir_keywords_write_fd(struct maildir_keywords *mk, ut.actime = ioloop_time; ut.modtime = mk->synced_mtime; if (utime(path, &ut) < 0) { - mail_storage_set_critical(mk->storage, + mailbox_set_critical(&mk->mbox->box, "utime(%s) failed: %m", path); return -1; } } if (fsync(fd) < 0) { - mail_storage_set_critical(mk->storage, + mailbox_set_critical(&mk->mbox->box, "fsync(%s) failed: %m", path); return -1; } @@ -380,7 +380,7 @@ static int maildir_keywords_commit(struct maildir_keywords *mk) break; if (errno != ENOENT || i == MAILDIR_DELETE_RETRY_COUNT) { - mail_storage_set_critical(mk->storage, + mailbox_set_critical(&mk->mbox->box, "file_dotlock_open(%s) failed: %m", mk->path); return -1; } @@ -396,7 +396,7 @@ static int maildir_keywords_commit(struct maildir_keywords *mk) } if (file_dotlock_replace(&dotlock, 0) < 0) { - mail_storage_set_critical(mk->storage, + mailbox_set_critical(&mk->mbox->box, "file_dotlock_replace(%s) failed: %m", mk->path); return -1; } diff --git a/src/lib-storage/index/maildir/maildir-mail.c b/src/lib-storage/index/maildir/maildir-mail.c index 7bf049d147..e7812da6ae 100644 --- a/src/lib-storage/index/maildir/maildir-mail.c +++ b/src/lib-storage/index/maildir/maildir-mail.c @@ -32,11 +32,11 @@ do_open(struct maildir_mailbox *mbox, const char *path, return 0; if (errno == EACCES) { - mail_storage_set_critical(&mbox->storage->storage, "%s", + mailbox_set_critical(&mbox->box, "%s", mail_error_eacces_msg("open", path)); } else { - mail_storage_set_critical(&mbox->storage->storage, - "open(%s) failed: %m", path); + mailbox_set_critical(&mbox->box, + "open(%s) failed: %m", path); } return -1; } @@ -50,11 +50,10 @@ do_stat(struct maildir_mailbox *mbox, const char *path, struct stat *st) return 0; if (errno == EACCES) { - mail_storage_set_critical(&mbox->storage->storage, "%s", + mailbox_set_critical(&mbox->box, "%s", mail_error_eacces_msg("stat", path)); } else { - mail_storage_set_critical(&mbox->storage->storage, - "stat(%s) failed: %m", path); + mailbox_set_critical(&mbox->box, "stat(%s) failed: %m", path); } return -1; } @@ -126,8 +125,7 @@ static int maildir_mail_stat(struct mail *mail, struct stat *st_r) (fd = i_stream_get_fd(imail->data.stream)) != -1) { mail->transaction->stats.fstat_lookup_count++; if (fstat(fd, st_r) < 0) { - mail_storage_set_critical(mail->box->storage, - "fstat(%s) failed: %m", + mail_set_critical(mail, "fstat(%s) failed: %m", i_stream_get_name(imail->data.stream)); return -1; } @@ -143,8 +141,7 @@ static int maildir_mail_stat(struct mail *mail, struct stat *st_r) mail->transaction->stats.stat_lookup_count++; path = maildir_save_file_get_path(mail->transaction, mail->seq); if (stat(path, st_r) < 0) { - mail_storage_set_critical(mail->box->storage, - "stat(%s) failed: %m", path); + mail_set_critical(mail, "stat(%s) failed: %m", path); return -1; } } @@ -476,8 +473,7 @@ static int maildir_mail_get_physical_size(struct mail *_mail, uoff_t *size_r) path = maildir_save_file_get_path(_mail->transaction, _mail->seq); if (stat(path, &st) < 0) { - mail_storage_set_critical(_mail->box->storage, - "stat(%s) failed: %m", path); + mail_set_critical(_mail, "stat(%s) failed: %m", path); return -1; } } @@ -520,10 +516,9 @@ maildir_mail_get_special(struct mail *_mail, enum mail_fetch_field field, return 0; } - mail_storage_set_critical(_mail->box->storage, - "Maildir %s: Corrupted dovecot-uidlist: " - "UID %u had empty GUID, clearing it", - mailbox_get_path(_mail->box), _mail->uid); + mail_set_critical(_mail, + "Maildir: Corrupted dovecot-uidlist: " + "UID had empty GUID, clearing it"); maildir_uidlist_unset_ext(mbox->uidlist, _mail->uid, MAILDIR_UIDLIST_REC_EXT_GUID); } @@ -680,8 +675,8 @@ do_fix_size(struct maildir_mailbox *mbox, const char *path, if (stat(path, &st) < 0) { if (errno == ENOENT) return 0; - mail_storage_set_critical(&mbox->storage->storage, - "stat(%s) failed: %m", path); + mailbox_set_critical(&mbox->box, + "stat(%s) failed: %m", path); return -1; } ctx->physical_size = st.st_size; @@ -692,7 +687,7 @@ do_fix_size(struct maildir_mailbox *mbox, const char *path, ctx->physical_size, info); if (rename(path, newpath) == 0) { - mail_storage_set_critical(mbox->box.storage, + mailbox_set_critical(&mbox->box, "Maildir filename has wrong %c value, " "renamed the file from %s to %s", ctx->wrong_key, path, newpath); @@ -701,8 +696,8 @@ do_fix_size(struct maildir_mailbox *mbox, const char *path, if (errno == ENOENT) return 0; - mail_storage_set_critical(&mbox->storage->storage, - "rename(%s, %s) failed: %m", path, newpath); + mailbox_set_critical(&mbox->box, "rename(%s, %s) failed: %m", + path, newpath); return -1; } diff --git a/src/lib-storage/index/maildir/maildir-save.c b/src/lib-storage/index/maildir/maildir-save.c index 0f6e1e341a..0d7d1dc5c8 100644 --- a/src/lib-storage/index/maildir/maildir-save.c +++ b/src/lib-storage/index/maildir/maildir-save.c @@ -109,8 +109,9 @@ static int maildir_file_move(struct maildir_save_context *ctx, MAIL_ERRSTR_NO_QUOTA); return -1; } else { - mail_storage_set_critical(storage, "rename(%s, %s) failed: %m", - tmp_path, new_path); + mail_set_critical(ctx->ctx.dest_mail, + "rename(%s, %s) failed: %m", + tmp_path, new_path); return -1; } } @@ -375,19 +376,19 @@ static int maildir_create_tmp(struct maildir_mailbox *mbox, const char *dir, mail_storage_set_error(box->storage, MAIL_ERROR_NOQUOTA, MAIL_ERRSTR_NO_QUOTA); } else { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "open(%s) failed: %m", str_c(path)); } } else if (perm->file_create_gid != (gid_t)-1) { if (fchown(fd, (uid_t)-1, perm->file_create_gid) < 0) { if (errno == EPERM) { - mail_storage_set_critical(box->storage, "%s", + mailbox_set_critical(box, "%s", eperm_error_get_chgrp("fchown", str_c(path), perm->file_create_gid, perm->file_create_gid_origin)); } else { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "fchown(%s) failed: %m", str_c(path)); } } @@ -462,7 +463,6 @@ int maildir_save_continue(struct mail_save_context *_ctx) static int maildir_save_finish_received_date(struct maildir_save_context *ctx, const char *path) { - struct mail_storage *storage = &ctx->mbox->storage->storage; struct utimbuf buf; struct stat st; @@ -472,16 +472,16 @@ static int maildir_save_finish_received_date(struct maildir_save_context *ctx, buf.modtime = ctx->ctx.data.received_date; if (utime(path, &buf) < 0) { - mail_storage_set_critical(storage, - "utime(%s) failed: %m", path); + mail_set_critical(ctx->ctx.dest_mail, + "utime(%s) failed: %m", path); return -1; } } else if (ctx->fd != -1) { if (fstat(ctx->fd, &st) == 0) ctx->ctx.data.received_date = st.st_mtime; else { - mail_storage_set_critical(storage, - "fstat(%s) failed: %m", path); + mail_set_critical(ctx->ctx.dest_mail, + "fstat(%s) failed: %m", path); return -1; } } else { @@ -489,8 +489,8 @@ static int maildir_save_finish_received_date(struct maildir_save_context *ctx, if (stat(path, &st) == 0) ctx->ctx.data.received_date = st.st_mtime; else { - mail_storage_set_critical(storage, - "stat(%s) failed: %m", path); + mail_set_critical(ctx->ctx.dest_mail, + "stat(%s) failed: %m", path); return -1; } } @@ -531,7 +531,7 @@ static int maildir_save_finish_real(struct mail_save_context *_ctx) path = t_strconcat(ctx->tmpdir, "/", ctx->file_last->tmp_name, NULL); if (!ctx->failed && o_stream_finish(_ctx->data.output) < 0) { if (!mail_storage_set_error_from_errno(storage)) { - mail_storage_set_critical(storage, + mail_set_critical(_ctx->dest_mail, "write(%s) failed: %s", path, o_stream_get_error(_ctx->data.output)); } @@ -571,7 +571,7 @@ static int maildir_save_finish_real(struct mail_save_context *_ctx) !ctx->failed) { if (fsync(ctx->fd) < 0) { if (!mail_storage_set_error_from_errno(storage)) { - mail_storage_set_critical(storage, + mail_set_critical(_ctx->dest_mail, "fsync(%s) failed: %m", path); } ctx->failed = TRUE; @@ -579,8 +579,7 @@ static int maildir_save_finish_real(struct mail_save_context *_ctx) } real_size = lseek(ctx->fd, 0, SEEK_END); if (real_size == (off_t)-1) { - mail_storage_set_critical(storage, - "lseek(%s) failed: %m", path); + mail_set_critical(_ctx->dest_mail, "lseek(%s) failed: %m", path); } else if (real_size != (off_t)ctx->file_last->size && (!maildir_filename_get_size(ctx->file_last->dest_basename, MAILDIR_EXTRA_FILE_SIZE, &size) || @@ -597,8 +596,8 @@ static int maildir_save_finish_real(struct mail_save_context *_ctx) } if (close(ctx->fd) < 0) { if (!mail_storage_set_error_from_errno(storage)) { - mail_storage_set_critical(storage, - "close(%s) failed: %m", path); + mail_set_critical(_ctx->dest_mail, + "close(%s) failed: %m", path); } ctx->failed = TRUE; } @@ -612,7 +611,7 @@ static int maildir_save_finish_real(struct mail_save_context *_ctx) mail_storage_set_error(storage, MAIL_ERROR_NOQUOTA, MAIL_ERRSTR_NO_QUOTA); } else if (output_errno != 0) { - mail_storage_set_critical(storage, + mail_set_critical(_ctx->dest_mail, "write(%s) failed: %s", path, output_errstr); } @@ -664,14 +663,14 @@ static int maildir_transaction_fsync_dirs(struct maildir_save_context *ctx, if (new_changed) { if (fdatasync_path(ctx->newdir) < 0) { - mail_storage_set_critical(storage, + mail_set_critical(ctx->ctx.dest_mail, "fdatasync_path(%s) failed: %m", ctx->newdir); return -1; } } if (cur_changed) { if (fdatasync_path(ctx->curdir) < 0) { - mail_storage_set_critical(storage, + mail_set_critical(ctx->ctx.dest_mail, "fdatasync_path(%s) failed: %m", ctx->curdir); return -1; } diff --git a/src/lib-storage/index/maildir/maildir-storage.c b/src/lib-storage/index/maildir/maildir-storage.c index 01859e7bbf..388128b40b 100644 --- a/src/lib-storage/index/maildir/maildir-storage.c +++ b/src/lib-storage/index/maildir/maildir-storage.c @@ -167,8 +167,7 @@ mkdir_verify(struct mailbox *box, const char *dir, bool verify) return 0; if (errno != ENOENT) { - mail_storage_set_critical(box->storage, - "stat(%s) failed: %m", dir); + mailbox_set_critical(box, "stat(%s) failed: %m", dir); return -1; } } @@ -194,11 +193,10 @@ mkdir_verify(struct mailbox *box, const char *dir, bool verify) MAIL_ERRSTR_NO_PERMISSION); return -1; } - mail_storage_set_critical(box->storage, "%s", + mailbox_set_critical(box, "%s", mail_error_create_eacces_msg("mkdir", dir)); } else { - mail_storage_set_critical(box->storage, - "mkdir(%s) failed: %m", dir); + mailbox_set_critical(box, "mkdir(%s) failed: %m", dir); } return -1; } @@ -383,8 +381,7 @@ static int maildir_mailbox_open(struct mailbox *box) T_MAIL_ERR_MAILBOX_NOT_FOUND(box->vname)); return -1; } else { - mail_storage_set_critical(box->storage, - "stat(%s) failed: %m", box_path); + mailbox_set_critical(box, "stat(%s) failed: %m", box_path); return -1; } } @@ -408,19 +405,18 @@ static int maildir_create_shared(struct mailbox *box) umask(old_mask); if (fd == -1) { - mail_storage_set_critical(box->storage, "open(%s) failed: %m", - path); + mailbox_set_critical(box, "open(%s) failed: %m", path); return -1; } if (fchown(fd, (uid_t)-1, perm->file_create_gid) < 0) { if (errno == EPERM) { - mail_storage_set_critical(box->storage, "%s", + mailbox_set_critical(box, "%s", eperm_error_get_chgrp("fchown", path, perm->file_create_gid, perm->file_create_gid_origin)); } else { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "fchown(%s) failed: %m", path); } } @@ -490,8 +486,7 @@ static int maildir_create_maildirfolder_file(struct mailbox *box) "Mailbox was deleted while it was being created"); return -1; } else { - mail_storage_set_critical(box->storage, - "open(%s, O_CREAT) failed: %m", path); + mailbox_set_critical(box, "open(%s, O_CREAT) failed: %m", path); return -1; } @@ -499,13 +494,12 @@ static int maildir_create_maildirfolder_file(struct mailbox *box) if (fchown(fd, (uid_t)-1, perm->file_create_gid) == 0) { /* ok */ } else if (errno == EPERM) { - mail_storage_set_critical(box->storage, "%s", + mailbox_set_critical(box, "%s", eperm_error_get_chgrp("fchown", path, perm->file_create_gid, perm->file_create_gid_origin)); } else { - mail_storage_set_critical(box->storage, - "fchown(%s) failed: %m", path); + mailbox_set_critical(box, "fchown(%s) failed: %m", path); } } i_close_fd(&fd); diff --git a/src/lib-storage/index/maildir/maildir-sync-index.c b/src/lib-storage/index/maildir/maildir-sync-index.c index 413871117c..f7f098a958 100644 --- a/src/lib-storage/index/maildir/maildir-sync-index.c +++ b/src/lib-storage/index/maildir/maildir-sync-index.c @@ -71,10 +71,9 @@ maildir_expunge_is_valid_guid(struct maildir_index_sync_context *ctx, if (memcmp(guid_128, expunged_guid_128, sizeof(guid_128)) == 0) return TRUE; - mail_storage_set_critical(&ctx->mbox->storage->storage, - "Mailbox %s: Expunged GUID mismatch for UID %u: %s vs %s", - ctx->mbox->box.vname, ctx->uid, - guid_128_to_string(guid_128), + mailbox_set_critical(&ctx->mbox->box, + "Expunged GUID mismatch for UID %u: %s vs %s", + ctx->uid, guid_128_to_string(guid_128), guid_128_to_string(expunged_guid_128)); return FALSE; } @@ -98,8 +97,7 @@ static int maildir_expunge(struct maildir_mailbox *mbox, const char *path, if (UNLINK_EISDIR(errno)) return maildir_lose_unexpected_dir(box->storage, path); - mail_storage_set_critical(&mbox->storage->storage, - "unlink(%s) failed: %m", path); + mailbox_set_critical(&mbox->box, "unlink(%s) failed: %m", path); return -1; } @@ -141,8 +139,7 @@ static int maildir_sync_flags(struct maildir_mailbox *mbox, const char *path, if (stat(path, &st) < 0) { if (errno == ENOENT) return 0; - mail_storage_set_critical(box->storage, - "stat(%s) failed: %m", path); + mailbox_set_critical(box, "stat(%s) failed: %m", path); return -1; } } else { @@ -150,7 +147,7 @@ static int maildir_sync_flags(struct maildir_mailbox *mbox, const char *path, if (errno == ENOENT) return 0; if (!ENOSPACE(errno) && errno != EACCES) { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "rename(%s, %s) failed: %m", path, newpath); } @@ -741,8 +738,7 @@ int maildir_list_index_has_changed(struct mailbox *box, /* check if new/ changed */ new_dir = t_strconcat(root_dir, "/new", NULL); if (stat(new_dir, &st) < 0) { - mail_storage_set_critical(box->storage, - "stat(%s) failed: %m", new_dir); + mailbox_set_critical(box, "stat(%s) failed: %m", new_dir); return -1; } if ((time_t)rec->new_mtime != st.st_mtime) @@ -751,8 +747,7 @@ int maildir_list_index_has_changed(struct mailbox *box, /* check if cur/ changed */ cur_dir = t_strconcat(root_dir, "/cur", NULL); if (stat(cur_dir, &st) < 0) { - mail_storage_set_critical(box->storage, - "stat(%s) failed: %m", cur_dir); + mailbox_set_critical(box, "stat(%s) failed: %m", cur_dir); return -1; } if ((time_t)rec->cur_mtime != st.st_mtime) diff --git a/src/lib-storage/index/maildir/maildir-sync.c b/src/lib-storage/index/maildir/maildir-sync.c index c3721ec756..8951cd78a8 100644 --- a/src/lib-storage/index/maildir/maildir-sync.c +++ b/src/lib-storage/index/maildir/maildir-sync.c @@ -347,7 +347,7 @@ static int maildir_fix_duplicate(struct maildir_sync_context *ctx, if (rename(path2, new_path) == 0) i_warning("Fixed a duplicate: %s -> %s", path2, new_fname); else if (errno != ENOENT) { - mail_storage_set_critical(&ctx->mbox->storage->storage, + mailbox_set_critical(&ctx->mbox->box, "Couldn't fix a duplicate: rename(%s, %s) failed: %m", path2, new_path); return -1; @@ -368,7 +368,7 @@ maildir_rename_empty_basename(struct maildir_sync_context *ctx, if (rename(old_path, new_path) == 0) i_warning("Fixed broken filename: %s -> %s", old_path, new_fname); else if (errno != ENOENT) { - mail_storage_set_critical(&ctx->mbox->storage->storage, + mailbox_set_critical(&ctx->mbox->box, "Couldn't fix a broken filename: rename(%s, %s) failed: %m", old_path, new_path); return -1; @@ -393,7 +393,7 @@ maildir_stat(struct maildir_mailbox *mbox, const char *path, struct stat *st_r) /* try again */ } - mail_storage_set_critical(box->storage, "stat(%s) failed: %m", path); + mailbox_set_critical(box, "stat(%s) failed: %m", path); return -1; } @@ -401,7 +401,6 @@ static int maildir_scan_dir(struct maildir_sync_context *ctx, bool new_dir, bool final, enum maildir_scan_why why) { - struct mail_storage *storage = &ctx->mbox->storage->storage; const char *path; DIR *dirp; string_t *src, *dest; @@ -421,10 +420,10 @@ maildir_scan_dir(struct maildir_sync_context *ctx, bool new_dir, bool final, if (errno != ENOENT || i == MAILDIR_DELETE_RETRY_COUNT) { if (errno == EACCES) { - mail_storage_set_critical(storage, "%s", + mailbox_set_critical(&ctx->mbox->box, "%s", eacces_error_get("opendir", path)); } else { - mail_storage_set_critical(storage, + mailbox_set_critical(&ctx->mbox->box, "opendir(%s) failed: %m", path); } return -1; @@ -437,7 +436,7 @@ maildir_scan_dir(struct maildir_sync_context *ctx, bool new_dir, bool final, #ifdef HAVE_DIRFD if (fstat(dirfd(dirp), &st) < 0) { - mail_storage_set_critical(storage, + mailbox_set_critical(&ctx->mbox->box, "fstat(%s) failed: %m", path); (void)closedir(dirp); return -1; @@ -510,7 +509,7 @@ maildir_scan_dir(struct maildir_sync_context *ctx, bool new_dir, bool final, move_new = FALSE; } else { flags |= MAILDIR_UIDLIST_REC_FLAG_NEW_DIR; - mail_storage_set_critical(storage, + mailbox_set_critical(&ctx->mbox->box, "rename(%s, %s) failed: %m", str_c(src), str_c(dest)); } @@ -550,14 +549,14 @@ maildir_scan_dir(struct maildir_sync_context *ctx, bool new_dir, bool final, #endif if (errno != 0) { - mail_storage_set_critical(storage, - "readdir(%s) failed: %m", path); + mailbox_set_critical(&ctx->mbox->box, + "readdir(%s) failed: %m", path); ret = -1; } if (closedir(dirp) < 0) { - mail_storage_set_critical(storage, - "closedir(%s) failed: %m", path); + mailbox_set_critical(&ctx->mbox->box, + "closedir(%s) failed: %m", path); ret = -1; } diff --git a/src/lib-storage/index/maildir/maildir-uidlist.c b/src/lib-storage/index/maildir/maildir-uidlist.c index be9b1f09d9..87684757e9 100644 --- a/src/lib-storage/index/maildir/maildir-uidlist.c +++ b/src/lib-storage/index/maildir/maildir-uidlist.c @@ -171,10 +171,10 @@ static int maildir_uidlist_lock_timeout(struct maildir_uidlist *uidlist, } if (errno != ENOENT || i == MAILDIR_DELETE_RETRY_COUNT) { if (errno == EACCES) { - mail_storage_set_critical(box->storage, "%s", + mailbox_set_critical(box, "%s", eacces_error_get_creating("file_dotlock_create", path)); } else { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "file_dotlock_create(%s) failed: %m", path); } @@ -294,11 +294,9 @@ struct maildir_uidlist *maildir_uidlist_init(struct maildir_mailbox *mbox) static void maildir_uidlist_close(struct maildir_uidlist *uidlist) { - struct mail_storage *storage = uidlist->box->storage; - if (uidlist->fd != -1) { if (close(uidlist->fd) < 0) { - mail_storage_set_critical(storage, + mailbox_set_critical(uidlist->box, "close(%s) failed: %m", uidlist->path); } uidlist->fd = -1; @@ -349,18 +347,17 @@ static void ATTR_FORMAT(2, 3) maildir_uidlist_set_corrupted(struct maildir_uidlist *uidlist, const char *fmt, ...) { - struct mail_storage *storage = uidlist->box->storage; va_list args; va_start(args, fmt); if (uidlist->retry_rewind) { - mail_storage_set_critical(storage, + mailbox_set_critical(uidlist->box, "Broken or unexpectedly changed file %s " "line %u: %s - re-reading from beginning", uidlist->path, uidlist->read_line_count, t_strdup_vprintf(fmt, args)); } else { - mail_storage_set_critical(storage, "Broken file %s line %u: %s", + mailbox_set_critical(uidlist->box, "Broken file %s line %u: %s", uidlist->path, uidlist->read_line_count, t_strdup_vprintf(fmt, args)); } @@ -701,7 +698,6 @@ static int maildir_uidlist_update_read(struct maildir_uidlist *uidlist, bool *retry_r, bool try_retry) { - struct mail_storage *storage = uidlist->box->storage; const char *line; uint32_t orig_next_uid, orig_uid_validity; struct istream *input; @@ -720,7 +716,7 @@ maildir_uidlist_update_read(struct maildir_uidlist *uidlist, } if (fd == -1) { if (errno != ENOENT) { - mail_storage_set_critical(storage, + mailbox_set_critical(uidlist->box, "open(%s) failed: %m", uidlist->path); return -1; } @@ -735,7 +731,7 @@ maildir_uidlist_update_read(struct maildir_uidlist *uidlist, *retry_r = TRUE; return -1; } - mail_storage_set_critical(storage, + mailbox_set_critical(uidlist->box, "lseek(%s) failed: %m", uidlist->path); return -1; } @@ -751,7 +747,7 @@ maildir_uidlist_update_read(struct maildir_uidlist *uidlist, *retry_r = TRUE; return -1; } - mail_storage_set_critical(storage, + mailbox_set_critical(uidlist->box, "fstat(%s) failed: %m", uidlist->path); return -1; } @@ -804,7 +800,7 @@ maildir_uidlist_update_read(struct maildir_uidlist *uidlist, orig_uid_validity != 0) { uidlist->recreate = TRUE; } else if (ret > 0 && uidlist->next_uid < orig_next_uid) { - mail_storage_set_critical(storage, + mailbox_set_critical(uidlist->box, "%s: next_uid was lowered (%u -> %u, hdr=%u)", uidlist->path, orig_next_uid, uidlist->next_uid, uidlist->hdr_next_uid); @@ -831,7 +827,7 @@ maildir_uidlist_update_read(struct maildir_uidlist *uidlist, if (input->stream_errno == ESTALE && try_retry) *retry_r = TRUE; else { - mail_storage_set_critical(storage, + mailbox_set_critical(uidlist->box, "read(%s) failed: %s", uidlist->path, i_stream_get_error(input)); } @@ -841,7 +837,7 @@ maildir_uidlist_update_read(struct maildir_uidlist *uidlist, i_stream_destroy(&input); if (ret <= 0) { if (close(fd) < 0) { - mail_storage_set_critical(storage, + mailbox_set_critical(uidlist->box, "close(%s) failed: %m", uidlist->path); } } @@ -859,7 +855,7 @@ maildir_uidlist_stat(struct maildir_uidlist *uidlist, struct stat *st_r) } if (nfs_safe_stat(uidlist->path, st_r) < 0) { if (errno != ENOENT) { - mail_storage_set_critical(storage, + mailbox_set_critical(uidlist->box, "stat(%s) failed: %m", uidlist->path); return -1; } @@ -900,7 +896,7 @@ maildir_uidlist_has_changed(struct maildir_uidlist *uidlist, bool *recreated_r) *recreated_r = TRUE; return 1; } - mail_storage_set_critical(storage, + mailbox_set_critical(uidlist->box, "fstat(%s) failed: %m", uidlist->path); return -1; } @@ -939,7 +935,7 @@ static int maildir_uidlist_open_latest(struct maildir_uidlist *uidlist) uidlist->recreate_on_change = TRUE; } if (uidlist->fd == -1 && errno != ENOENT) { - mail_storage_set_critical(uidlist->box->storage, + mailbox_set_critical(uidlist->box, "open(%s) failed: %m", uidlist->path); return -1; } @@ -1311,8 +1307,8 @@ static int maildir_uidlist_write_fd(struct maildir_uidlist *uidlist, int fd, maildir_uidlist_iter_deinit(&iter); if (o_stream_finish(output) < 0) { - mail_storage_set_critical(storage, "write(%s) failed: %s", path, - o_stream_get_error(output)); + mailbox_set_critical(uidlist->box, "write(%s) failed: %s", + path, o_stream_get_error(output)); o_stream_unref(&output); return -1; } @@ -1322,7 +1318,7 @@ static int maildir_uidlist_write_fd(struct maildir_uidlist *uidlist, int fd, if (storage->set->parsed_fsync_mode != FSYNC_MODE_NEVER) { if (fdatasync(fd) < 0) { - mail_storage_set_critical(storage, + mailbox_set_critical(uidlist->box, "fdatasync(%s) failed: %m", path); return -1; } @@ -1418,7 +1414,7 @@ static int maildir_uidlist_recreate(struct maildir_uidlist *uidlist) break; if (errno != ENOENT || i == MAILDIR_DELETE_RETRY_COUNT) { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "open(%s, O_CREAT) failed: %m", temp_path); return -1; } @@ -1431,12 +1427,12 @@ static int maildir_uidlist_recreate(struct maildir_uidlist *uidlist) if (perm->file_create_gid != (gid_t)-1 && fchown(fd, (uid_t)-1, perm->file_create_gid) < 0) { if (errno == EPERM) { - mail_storage_set_critical(box->storage, "%s", + mailbox_set_critical(box, "%s", eperm_error_get_chgrp("fchown", temp_path, perm->file_create_gid, perm->file_create_gid_origin)); } else { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "fchown(%s) failed: %m", temp_path); } } @@ -1445,7 +1441,7 @@ static int maildir_uidlist_recreate(struct maildir_uidlist *uidlist) ret = maildir_uidlist_write_fd(uidlist, fd, temp_path, 0, &file_size); if (ret == 0) { if (rename(temp_path, uidlist->path) < 0) { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "rename(%s, %s) failed: %m", temp_path, uidlist->path); ret = -1; @@ -1455,12 +1451,12 @@ static int maildir_uidlist_recreate(struct maildir_uidlist *uidlist) if (ret < 0) i_unlink(temp_path); else if (fstat(fd, &st) < 0) { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "fstat(%s) failed: %m", temp_path); ret = -1; } else if (file_size != (uoff_t)st.st_size) { i_assert(!file_dotlock_is_locked(uidlist->dotlock)); - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "Maildir uidlist dotlock overridden: %s", uidlist->path); ret = -1; @@ -1528,7 +1524,6 @@ static bool maildir_uidlist_want_recreate(struct maildir_uidlist_sync_ctx *ctx) static int maildir_uidlist_sync_update(struct maildir_uidlist_sync_ctx *ctx) { struct maildir_uidlist *uidlist = ctx->uidlist; - struct mail_storage *storage = uidlist->box->storage; struct stat st; uoff_t file_size; @@ -1546,7 +1541,7 @@ static int maildir_uidlist_sync_update(struct maildir_uidlist_sync_ctx *ctx) i_assert(ctx->first_unwritten_pos != UINT_MAX); if (lseek(uidlist->fd, 0, SEEK_END) < 0) { - mail_storage_set_critical(storage, + mailbox_set_critical(uidlist->box, "lseek(%s) failed: %m", uidlist->path); return -1; } @@ -1556,7 +1551,7 @@ static int maildir_uidlist_sync_update(struct maildir_uidlist_sync_ctx *ctx) return -1; if (fstat(uidlist->fd, &st) < 0) { - mail_storage_set_critical(storage, + mailbox_set_critical(uidlist->box, "fstat(%s) failed: %m", uidlist->path); return -1; } @@ -1710,7 +1705,7 @@ maildir_uidlist_sync_next_partial(struct maildir_uidlist_sync_ctx *ctx, } if (uid != 0) { if (rec->uid != uid && rec->uid != (uint32_t)-1) { - mail_storage_set_critical(uidlist->box->storage, + mailbox_set_critical(uidlist->box, "Maildir: %s changed UID %u -> %u", filename, rec->uid, uid); return -1; diff --git a/src/lib-storage/index/maildir/maildir-util.c b/src/lib-storage/index/maildir/maildir-util.c index 1233bfc411..488e933315 100644 --- a/src/lib-storage/index/maildir/maildir-util.c +++ b/src/lib-storage/index/maildir/maildir-util.c @@ -127,16 +127,15 @@ static int do_racecheck(struct maildir_mailbox *mbox, const char *path, ret = lstat(path, &st); if (ret == 0 && (st.st_mode & S_IFMT) == S_IFLNK) { /* most likely a symlink pointing to a nonexistent file */ - mail_storage_set_critical(&mbox->storage->storage, + mailbox_set_critical(&mbox->box, "Maildir: Symlink destination doesn't exist for UID=%u: %s", *uidp, path); return -2; } else if (ret < 0 && errno != ENOENT) { - mail_storage_set_critical(&mbox->storage->storage, - "lstat(%s) failed: %m", path); + mailbox_set_critical(&mbox->box, "lstat(%s) failed: %m", path); return -1; } else { /* success or ENOENT, either way we're done */ - mail_storage_set_critical(&mbox->storage->storage, + mailbox_set_critical(&mbox->box, "maildir_file_do(%s): Filename keeps changing for UID=%u", path, *uidp); return -1; } @@ -205,8 +204,7 @@ static int maildir_create_path(struct mailbox *box, const char *path, /* should work now, try again */ return maildir_create_path(box, path, type, FALSE); default: - mail_storage_set_critical(box->storage, - "mkdir(%s) failed: %m", path); + mailbox_set_critical(box, "mkdir(%s) failed: %m", path); return -1; } } @@ -242,8 +240,7 @@ static int maildir_create_subdirs(struct mailbox *box) if (stat(path, &st) == 0) continue; if (errno != ENOENT) { - mail_storage_set_critical(box->storage, - "stat(%s) failed: %m", path); + mailbox_set_critical(box, "stat(%s) failed: %m", path); break; } if (maildir_create_path(box, path, types[i], TRUE) < 0) @@ -261,7 +258,7 @@ bool maildir_set_deleted(struct mailbox *box) if (errno == ENOENT) mailbox_set_deleted(box); else { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "stat(%s) failed: %m", mailbox_get_path(box)); } return FALSE; diff --git a/src/lib-storage/index/mbox/mbox-file.c b/src/lib-storage/index/mbox/mbox-file.c index 10112f7ae9..130808f046 100644 --- a/src/lib-storage/index/mbox/mbox-file.c +++ b/src/lib-storage/index/mbox/mbox-file.c @@ -150,9 +150,8 @@ int mbox_file_lookup_offset(struct mbox_mailbox *mbox, return -1; if (data == NULL) { - mail_storage_set_critical(&mbox->storage->storage, - "Cached message offset lost for seq %u in mbox file %s", - seq, mailbox_get_path(&mbox->box)); + mailbox_set_critical(&mbox->box, + "Cached message offset lost for seq %u in mbox", seq); mbox->mbox_hdr.dirty_flag = 1; mbox->mbox_broken_offsets = TRUE; return 0; @@ -187,9 +186,9 @@ int mbox_file_seek(struct mbox_mailbox *mbox, struct mail_index_view *view, if (mbox->mbox_hdr.dirty_flag != 0) return 0; - mail_storage_set_critical(&mbox->storage->storage, - "Cached message offset %s is invalid for mbox file %s", - dec2str(offset), mailbox_get_path(&mbox->box)); + mailbox_set_critical(&mbox->box, + "Cached message offset %s is invalid for mbox", + dec2str(offset)); mbox->mbox_hdr.dirty_flag = 1; mbox->mbox_broken_offsets = TRUE; return 0; diff --git a/src/lib-storage/index/mbox/mbox-lock.c b/src/lib-storage/index/mbox/mbox-lock.c index 7542241cfe..e97d7242c1 100644 --- a/src/lib-storage/index/mbox/mbox-lock.c +++ b/src/lib-storage/index/mbox/mbox-lock.c @@ -257,8 +257,7 @@ mbox_dotlock_privileged_op(struct mbox_mailbox *mbox, orig_dir_fd = open(".", O_RDONLY); if (orig_dir_fd == -1) { - mail_storage_set_critical(&mbox->storage->storage, - "open(.) failed: %m"); + mailbox_set_critical(&mbox->box, "open(.) failed: %m"); return -1; } @@ -278,7 +277,7 @@ mbox_dotlock_privileged_op(struct mbox_mailbox *mbox, } else { dir = t_strdup_until(box_path, fname); if (chdir(dir) < 0) { - mail_storage_set_critical(&mbox->storage->storage, + mailbox_set_critical(&mbox->box, "chdir(%s) failed: %m", dir); i_close_fd(&orig_dir_fd); return -1; @@ -287,7 +286,7 @@ mbox_dotlock_privileged_op(struct mbox_mailbox *mbox, } if (op == MBOX_DOTLOCK_OP_LOCK) { if (access(fname, R_OK) < 0) { - mail_storage_set_critical(&mbox->storage->storage, + mailbox_set_critical(&mbox->box, "access(%s) failed: %m", box_path); i_close_fd(&orig_dir_fd); return -1; @@ -309,8 +308,7 @@ mbox_dotlock_privileged_op(struct mbox_mailbox *mbox, const char *errmsg = eacces_error_get_creating("file_dotlock_create", fname); - mail_storage_set_critical(&mbox->storage->storage, - "%s", errmsg); + mailbox_set_critical(&mbox->box, "%s", errmsg); } else { mbox_set_syscall_error(mbox, "file_dotlock_create()"); } @@ -333,8 +331,7 @@ mbox_dotlock_privileged_op(struct mbox_mailbox *mbox, restrict_access_drop_priv_gid(); if (fchdir(orig_dir_fd) < 0) { - mail_storage_set_critical(&mbox->storage->storage, - "fchdir() failed: %m"); + mailbox_set_critical(&mbox->box, "fchdir() failed: %m"); } i_close_fd(&orig_dir_fd); errno = orig_errno; @@ -357,12 +354,12 @@ mbox_dotlock_log_eacces_error(struct mbox_mailbox *mbox, const char *path) b) another user's shared INBOX, and c) anything called INBOX (in inbox=no namespace) */ if (!mbox->box.inbox_any && strcmp(mbox->box.name, "INBOX") != 0) { - mail_storage_set_critical(&mbox->storage->storage, + mailbox_set_critical(&mbox->box, "%s (not INBOX -> no privileged locking)", errmsg); } else if (!mbox->mbox_privileged_locking) { dir = mailbox_list_get_root_forced(mbox->box.list, MAILBOX_LIST_PATH_TYPE_DIR); - mail_storage_set_critical(&mbox->storage->storage, + mailbox_set_critical(&mbox->box, "%s (under root dir %s -> no privileged locking)", errmsg, dir); } else if (stat(dir, &st) == 0 && @@ -372,10 +369,10 @@ mbox_dotlock_log_eacces_error(struct mbox_mailbox *mbox, const char *path) name = dec2str(st.st_gid); else name = group.gr_name; - mail_storage_set_critical(&mbox->storage->storage, + mailbox_set_critical(&mbox->box, "%s (set mail_privileged_group=%s)", errmsg, name); } else { - mail_storage_set_critical(&mbox->storage->storage, + mailbox_set_critical(&mbox->box, "%s (nonstandard permissions in %s)", errmsg, dir); } errno = orig_errno; @@ -638,7 +635,7 @@ static int mbox_lock_fcntl(struct mbox_lock_context *ctx, int lock_type, mbox_set_syscall_error(ctx->mbox, "fcntl()"); return -1; } - mail_storage_set_critical(&ctx->mbox->storage->storage, + mailbox_set_critical(&ctx->mbox->box, "fcntl() failed with mbox file %s: " "File is locked by another process (EACCES)", mailbox_get_path(&ctx->mbox->box)); diff --git a/src/lib-storage/index/mbox/mbox-mail.c b/src/lib-storage/index/mbox/mbox-mail.c index 0ee2c729fa..10839c97f2 100644 --- a/src/lib-storage/index/mbox/mbox-mail.c +++ b/src/lib-storage/index/mbox/mbox-mail.c @@ -102,9 +102,7 @@ static int mbox_mail_seek(struct index_mail *mail) sync_flags |= MBOX_SYNC_UNDIRTY | MBOX_SYNC_FORCE_SYNC; } if (ret == 0) { - mail_storage_set_critical(&mbox->storage->storage, - "Losing sync for mail uid=%u in mbox file %s", - _mail->uid, mailbox_get_path(&mbox->box)); + mail_set_critical(_mail, "mbox: Losing sync"); } return 0; } @@ -304,9 +302,7 @@ static int mbox_mail_get_physical_size(struct mail *_mail, uoff_t *size_r) /* our header size varies, so don't do any caching */ if (istream_raw_mbox_get_body_offset(mbox->mbox_stream, &body_offset) < 0) { - mail_storage_set_critical(_mail->box->storage, - "mbox %s: Couldn't get body offset for uid=%u", - mailbox_get_path(&mbox->box), mail->mail.mail.uid); + mail_set_critical(_mail, "mbox: Couldn't get body offset"); return -1; } @@ -320,9 +316,7 @@ static int mbox_mail_get_physical_size(struct mail *_mail, uoff_t *size_r) /* verify that the calculated body size is correct */ if (istream_raw_mbox_get_body_size(mbox->mbox_stream, body_size, &body_size) < 0) { - mail_storage_set_critical(_mail->box->storage, - "mbox %s: Couldn't get body size for uid=%u", - mailbox_get_path(&mbox->box), mail->mail.mail.uid); + mail_set_critical(_mail, "mbox: Couldn't get body size"); return -1; } @@ -357,9 +351,8 @@ static int mbox_mail_init_stream(struct index_mail *mail) raw_stream = mbox->mbox_stream; if (istream_raw_mbox_get_header_offset(raw_stream, &hdr_offset) < 0) { - mail_storage_set_critical(mbox->box.storage, - "mbox %s: Couldn't get header offset for uid=%u", - mailbox_get_path(&mbox->box), mail->mail.mail.uid); + mail_set_critical(&mail->mail.mail, + "mbox: Couldn't get header offset"); return -1; } i_stream_seek(raw_stream, hdr_offset); diff --git a/src/lib-storage/index/mbox/mbox-storage.c b/src/lib-storage/index/mbox/mbox-storage.c index f761011007..2a35a518b5 100644 --- a/src/lib-storage/index/mbox/mbox-storage.c +++ b/src/lib-storage/index/mbox/mbox-storage.c @@ -78,9 +78,8 @@ void mbox_set_syscall_error(struct mbox_mailbox *mbox, const char *function) } else { const char *toobig_error = errno != EFBIG ? "" : " (process was started with ulimit -f limit)"; - mail_storage_set_critical(&mbox->storage->storage, - "%s failed with mbox file %s: %m%s", function, - mailbox_get_path(&mbox->box), toobig_error); + mailbox_set_critical(&mbox->box, + "%s failed with mbox: %m%s", function, toobig_error); } } @@ -499,7 +498,7 @@ static int mbox_mailbox_open(struct mailbox *box) } else if (mail_storage_set_error_from_errno(box->storage)) { return -1; } else { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "stat(%s) failed: %m", mailbox_get_path(box)); return -1; } @@ -546,7 +545,7 @@ static int create_inbox(struct mailbox *box) i_close_fd(&fd); return 0; } else if (errno == EACCES) { - mail_storage_set_critical(box->storage, "%s", + mailbox_set_critical(box, "%s", mail_error_create_eacces_msg("open", inbox_path)); return -1; } else if (errno == EEXIST) { @@ -554,7 +553,7 @@ static int create_inbox(struct mailbox *box) "Mailbox already exists"); return -1; } else { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "open(%s, O_CREAT) failed: %m", inbox_path); return -1; } diff --git a/src/lib-storage/index/mbox/mbox-sync-list-index.c b/src/lib-storage/index/mbox/mbox-sync-list-index.c index 9f499aa728..84e3c836e0 100644 --- a/src/lib-storage/index/mbox/mbox-sync-list-index.c +++ b/src/lib-storage/index/mbox/mbox-sync-list-index.c @@ -50,8 +50,7 @@ int mbox_list_index_has_changed(struct mailbox *box, i_assert(ret > 0); if (stat(path, &st) < 0) { - mail_storage_set_critical(box->storage, - "stat(%s) failed: %m", path); + mailbox_set_critical(box, "stat(%s) failed: %m", path); return -1; } if ((time_t)rec->mtime != st.st_mtime || diff --git a/src/lib-storage/index/mbox/mbox-sync-rewrite.c b/src/lib-storage/index/mbox/mbox-sync-rewrite.c index a15f3f54d2..fd4f3e073c 100644 --- a/src/lib-storage/index/mbox/mbox-sync-rewrite.c +++ b/src/lib-storage/index/mbox/mbox-sync-rewrite.c @@ -42,14 +42,14 @@ int mbox_move(struct mbox_sync_context *sync_ctx, input = i_stream_create_limit(sync_ctx->file_input, size); (void)o_stream_send_istream(output, input); if (input->stream_errno != 0) { - mail_storage_set_critical(&mbox->storage->storage, - "read() failed with mbox file %s: %s", - mailbox_get_path(&mbox->box), i_stream_get_error(input)); + mailbox_set_critical(&mbox->box, + "read() failed with mbox: %s", + i_stream_get_error(input)); ret = -1; } else if (output->stream_errno != 0) { - mail_storage_set_critical(&mbox->storage->storage, - "write() failed with mbox file %s: %s", - mailbox_get_path(&mbox->box), o_stream_get_error(output)); + mailbox_set_critical(&mbox->box, + "write() failed with mbox: %s", + o_stream_get_error(output)); ret = -1; } else if (input->v_offset != size) { mbox_sync_set_critical(sync_ctx, diff --git a/src/lib-storage/index/mbox/mbox-sync.c b/src/lib-storage/index/mbox/mbox-sync.c index afcbbf0087..cb36f835d8 100644 --- a/src/lib-storage/index/mbox/mbox-sync.c +++ b/src/lib-storage/index/mbox/mbox-sync.c @@ -71,17 +71,15 @@ void mbox_sync_set_critical(struct mbox_sync_context *sync_ctx, sync_ctx->errors = TRUE; if (sync_ctx->ext_modified) { - mail_storage_set_critical(&sync_ctx->mbox->storage->storage, - "mbox file %s was modified while we were syncing, " - "check your locking settings", - mailbox_get_path(&sync_ctx->mbox->box)); + mailbox_set_critical(&sync_ctx->mbox->box, + "mbox was modified while we were syncing, " + "check your locking settings"); } va_start(va, fmt); - mail_storage_set_critical(&sync_ctx->mbox->storage->storage, - "Sync failed for mbox file %s: %s", - mailbox_get_path(&sync_ctx->mbox->box), - t_strdup_vprintf(fmt, va)); + mailbox_set_critical(&sync_ctx->mbox->box, + "Sync failed for mbox: %s", + t_strdup_vprintf(fmt, va)); va_end(va); } @@ -1136,11 +1134,8 @@ static int mbox_sync_loop(struct mbox_sync_context *sync_ctx, /* oh no, we're out of UIDs. this shouldn't happen normally, so just try to get it fixed without crashing. */ - mail_storage_set_critical( - &sync_ctx->mbox->storage->storage, - "Out of UIDs, renumbering them in mbox " - "file %s", - mailbox_get_path(&sync_ctx->mbox->box)); + mailbox_set_critical(&sync_ctx->mbox->box, + "Out of UIDs, renumbering them in mbox"); sync_ctx->renumber_uids = TRUE; return 0; } diff --git a/src/lib-storage/index/pop3c/pop3c-storage.c b/src/lib-storage/index/pop3c/pop3c-storage.c index 4928939046..62d7223de7 100644 --- a/src/lib-storage/index/pop3c/pop3c-storage.c +++ b/src/lib-storage/index/pop3c/pop3c-storage.c @@ -153,7 +153,7 @@ static void pop3c_login_callback(enum pop3c_command_state state, } break; case POP3C_COMMAND_STATE_DISCONNECTED: - mail_storage_set_critical(mbox->box.storage, + mailbox_set_critical(&mbox->box, "pop3c: Disconnected from remote server"); break; } diff --git a/src/lib-storage/index/pop3c/pop3c-sync.c b/src/lib-storage/index/pop3c/pop3c-sync.c index edfe91fc6a..868b148371 100644 --- a/src/lib-storage/index/pop3c/pop3c-sync.c +++ b/src/lib-storage/index/pop3c/pop3c-sync.c @@ -39,8 +39,7 @@ int pop3c_sync_get_uidls(struct pop3c_mailbox *mbox) if (pop3c_client_cmd_stream(mbox->client, "UIDL\r\n", &input, &error) < 0) { - mail_storage_set_critical(mbox->box.storage, - "UIDL failed: %s", error); + mailbox_set_critical(&mbox->box, "UIDL failed: %s", error); return -1; } @@ -50,13 +49,13 @@ int pop3c_sync_get_uidls(struct pop3c_mailbox *mbox) seq++; p = strchr(line, ' '); if (p == NULL) { - mail_storage_set_critical(mbox->box.storage, + mailbox_set_critical(&mbox->box, "Invalid UIDL line: %s", line); break; } *p++ = '\0'; if (str_to_uint(line, &line_seq) < 0 || line_seq != seq) { - mail_storage_set_critical(mbox->box.storage, + mailbox_set_critical(&mbox->box, "Unexpected UIDL seq: %s != %u", line, seq); break; } @@ -98,32 +97,31 @@ int pop3c_sync_get_sizes(struct pop3c_mailbox *mbox) if (pop3c_client_cmd_stream(mbox->client, "LIST\r\n", &input, &error) < 0) { - mail_storage_set_critical(mbox->box.storage, - "LIST failed: %s", error); + mailbox_set_critical(&mbox->box, "LIST failed: %s", error); return -1; } mbox->msg_sizes = i_new(uoff_t, mbox->msg_count); seq = 0; while ((line = i_stream_read_next_line(input)) != NULL) { if (++seq > mbox->msg_count) { - mail_storage_set_critical(mbox->box.storage, + mailbox_set_critical(&mbox->box, "Too much data in LIST: %s", line); break; } p = strchr(line, ' '); if (p == NULL) { - mail_storage_set_critical(mbox->box.storage, + mailbox_set_critical(&mbox->box, "Invalid LIST line: %s", line); break; } *p++ = '\0'; if (str_to_uint(line, &line_seq) < 0 || line_seq != seq) { - mail_storage_set_critical(mbox->box.storage, + mailbox_set_critical(&mbox->box, "Unexpected LIST seq: %s != %u", line, seq); break; } if (str_to_uoff(p, &mbox->msg_sizes[seq-1]) < 0) { - mail_storage_set_critical(mbox->box.storage, + mailbox_set_critical(&mbox->box, "Invalid LIST size: %s", p); break; } diff --git a/src/lib-storage/index/raw/raw-mail.c b/src/lib-storage/index/raw/raw-mail.c index 79ab8f3ae7..8e8d84d065 100644 --- a/src/lib-storage/index/raw/raw-mail.c +++ b/src/lib-storage/index/raw/raw-mail.c @@ -22,9 +22,8 @@ static int raw_mail_stat(struct mail *mail) mail->transaction->stats.fstat_lookup_count++; if (i_stream_stat(mail->box->input, TRUE, &st) < 0) { - mail_storage_set_critical(mail->box->storage, - "stat(%s) failed: %m", - i_stream_get_name(mail->box->input)); + mail_set_critical(mail, "stat(%s) failed: %m", + i_stream_get_name(mail->box->input)); return -1; } diff --git a/src/lib-storage/index/raw/raw-storage.c b/src/lib-storage/index/raw/raw-storage.c index d1f3147007..32f578c7c1 100644 --- a/src/lib-storage/index/raw/raw-storage.c +++ b/src/lib-storage/index/raw/raw-storage.c @@ -165,8 +165,7 @@ static int raw_mailbox_open(struct mailbox *box) MAIL_ERROR_NOTFOUND, T_MAIL_ERR_MAILBOX_NOT_FOUND(box->vname)); } else if (!mail_storage_set_error_from_errno(box->storage)) { - mail_storage_set_critical(box->storage, - "open(%s) failed: %m", path); + mailbox_set_critical(box, "open(%s) failed: %m", path); } return -1; } diff --git a/src/lib-storage/list/mailbox-list-index-backend.c b/src/lib-storage/list/mailbox-list-index-backend.c index 2744a72487..44cebec08c 100644 --- a/src/lib-storage/list/mailbox-list-index-backend.c +++ b/src/lib-storage/list/mailbox-list-index-backend.c @@ -459,9 +459,8 @@ index_list_mailbox_update(struct mailbox *box, T_MAIL_ERR_MAILBOX_NOT_FOUND(box->name)); return -1; } else { - mail_storage_set_critical(box->storage, - "rename(%s, %s) failed: %m", - old_path, new_path); + mailbox_set_critical(box, "rename(%s, %s) failed: %m", + old_path, new_path); return -1; } } diff --git a/src/lib-storage/mail-copy.c b/src/lib-storage/mail-copy.c index 2d344ad518..39a8fa3625 100644 --- a/src/lib-storage/mail-copy.c +++ b/src/lib-storage/mail-copy.c @@ -85,7 +85,7 @@ mail_storage_try_copy(struct mail_save_context **_ctx, struct mail *mail) } while (ret != -1); if (input->stream_errno != 0) { - mail_storage_set_critical(ctx->transaction->box->storage, + mailbox_set_critical(ctx->transaction->box, "copy: i_stream_read(%s) failed: %s", i_stream_get_name(input), i_stream_get_error(input)); return -1; diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index e20c79d547..b0134d5c46 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -957,16 +957,15 @@ static int mailbox_autocreate(struct mailbox *box) if (mailbox_create(box, NULL, FALSE) < 0) { errstr = mailbox_get_last_internal_error(box, &error); if (error != MAIL_ERROR_EXISTS) { - mail_storage_set_critical(box->storage, - "Failed to autocreate mailbox %s: %s", - box->vname, errstr); + mailbox_set_critical(box, + "Failed to autocreate mailbox: %s", + errstr); return -1; } } else if (mailbox_is_autosubscribed(box)) { if (mailbox_set_subscribed(box, TRUE) < 0) { - mail_storage_set_critical(box->storage, - "Failed to autosubscribe to mailbox %s: %s", - box->vname, + mailbox_set_critical(box, + "Failed to autosubscribe to mailbox: %s", mailbox_get_last_internal_error(box, NULL)); return -1; } @@ -986,7 +985,7 @@ static int mailbox_autocreate_and_reopen(struct mailbox *box) if (ret < 0 && box->inbox_user && !box->storage->user->inbox_open_error_logged) { box->storage->user->inbox_open_error_logged = TRUE; - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "Opening INBOX failed: %s", mailbox_get_last_internal_error(box, NULL)); } @@ -1270,7 +1269,7 @@ mailbox_open_full(struct mailbox *box, struct istream *input) if (input != NULL) { if ((box->storage->class_flags & MAIL_STORAGE_CLASS_FLAG_OPEN_STREAMS) == 0) { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "Storage doesn't support streamed mailboxes"); return -1; } @@ -2714,8 +2713,7 @@ int mailbox_create_fd(struct mailbox *box, const char *path, int flags, } else if (mail_storage_set_error_from_errno(box->storage)) { return -1; } else { - mail_storage_set_critical(box->storage, - "open(%s, O_CREAT) failed: %m", path); + mailbox_set_critical(box, "open(%s, O_CREAT) failed: %m", path); return -1; } @@ -2723,12 +2721,12 @@ int mailbox_create_fd(struct mailbox *box, const char *path, int flags, if (fchown(fd, (uid_t)-1, perm->file_create_gid) == 0) { /* ok */ } else if (errno == EPERM) { - mail_storage_set_critical(box->storage, "%s", + mailbox_set_critical(box, "%s", eperm_error_get_chgrp("fchown", path, perm->file_create_gid, perm->file_create_gid_origin)); } else { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "fchown(%s) failed: %m", path); } } @@ -2764,8 +2762,7 @@ int mailbox_mkdir(struct mailbox *box, const char *path, } else if (mail_storage_set_error_from_errno(box->storage)) { return -1; } else { - mail_storage_set_critical(box->storage, - "mkdir_parents(%s) failed: %m", path); + mailbox_set_critical(box, "mkdir_parents(%s) failed: %m", path); return -1; } } diff --git a/src/lib-storage/mailbox-recent-flags.c b/src/lib-storage/mailbox-recent-flags.c index 6b269c72a6..b8d58b3efc 100644 --- a/src/lib-storage/mailbox-recent-flags.c +++ b/src/lib-storage/mailbox-recent-flags.c @@ -10,9 +10,7 @@ void mailbox_recent_flags_set_uid(struct mailbox *box, uint32_t uid) if (seq_range_exists(&box->recent_flags, uid)) return; - mail_storage_set_critical(box->storage, - "Recent flags state corrupted for mailbox %s", - box->vname); + mailbox_set_critical(box, "Recent flags state corrupted"); array_clear(&box->recent_flags); box->recent_flags_count = 0; } diff --git a/src/plugins/acl/acl-mailbox.c b/src/plugins/acl/acl-mailbox.c index 4efcc0f103..732a5d0fba 100644 --- a/src/plugins/acl/acl-mailbox.c +++ b/src/plugins/acl/acl-mailbox.c @@ -645,7 +645,7 @@ int acl_mailbox_update_acl(struct mailbox_transaction_context *t, acl_rights_get_id(&update->rights)); aclobj = acl_mailbox_get_aclobj(t->box); if (acl_object_update(aclobj, update) < 0) { - mail_storage_set_critical(t->box->storage, "Failed to set ACL"); + mailbox_set_critical(t->box, "Failed to set ACL"); return -1; } diff --git a/src/plugins/fts/fts-storage.c b/src/plugins/fts/fts-storage.c index 4a04b2b20c..ee8e6d948e 100644 --- a/src/plugins/fts/fts-storage.c +++ b/src/plugins/fts/fts-storage.c @@ -723,9 +723,7 @@ static int fts_sync_deinit(struct mailbox_sync_context *ctx, if (optimize) { if (fts_backend_optimize(flist->backend) < 0) { - mail_storage_set_critical(box->storage, - "FTS optimize for mailbox %s failed", - box->vname); + mailbox_set_critical(box, "FTS optimize failed"); ret = -1; } } diff --git a/src/plugins/lazy-expunge/lazy-expunge-plugin.c b/src/plugins/lazy-expunge/lazy-expunge-plugin.c index b1e8b593ba..10acd567cf 100644 --- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c +++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c @@ -190,7 +190,7 @@ static int lazy_expunge_mail_is_last_instance(struct mail *_mail) /* already expunged - just ignore it */ return 0; } - mail_storage_set_critical(_mail->box->storage, + mail_set_critical(_mail, "lazy_expunge: Couldn't lookup message's refcount: %s", errstr); return -1; @@ -215,14 +215,14 @@ static int lazy_expunge_mail_is_last_instance(struct mail *_mail) /* already expunged - just ignore it */ return 0; } - mail_storage_set_critical(_mail->box->storage, + mail_set_critical(_mail, "lazy_expunge: Couldn't lookup message's GUID: %s", errstr); return -1; } if (*value == '\0') { /* GUIDs not supported by backend, but refcounts are? not with our current backends. */ - mail_storage_set_critical(_mail->box->storage, + mail_set_critical(_mail, "lazy_expunge: Message unexpectedly has no GUID"); return -1; } @@ -332,14 +332,14 @@ static void lazy_expunge_mail_expunge(struct mail *_mail) lt->dest_box = mailbox_open_or_create(luser->lazy_ns->list, _mail->box, &error); if (lt->dest_box == NULL) { - mail_storage_set_critical(_mail->box->storage, + mail_set_critical(_mail, "lazy_expunge: Couldn't open expunge mailbox: " "%s", error); lazy_expunge_set_error(lt, _mail->box->storage); return; } if (mailbox_sync(lt->dest_box, 0) < 0) { - mail_storage_set_critical(_mail->box->storage, + mail_set_critical(_mail, "lazy_expunge: Couldn't sync expunge mailbox"); lazy_expunge_set_error(lt, lt->dest_box->storage); mailbox_free(<->dest_box); @@ -428,7 +428,7 @@ lazy_expunge_transaction_commit(struct mailbox_transaction_context *ctx, mbox->super.transaction_rollback(ctx); ret = -1; } else { - mail_storage_set_critical(ctx->box->storage, + mailbox_set_critical(ctx->box, "Lazy-expunge transaction failed: %s", lt->delayed_internal_errstr); mbox->super.transaction_rollback(ctx); diff --git a/src/plugins/mailbox-alias/mailbox-alias-plugin.c b/src/plugins/mailbox-alias/mailbox-alias-plugin.c index 5c4474310d..77667dd4ab 100644 --- a/src/plugins/mailbox-alias/mailbox-alias-plugin.c +++ b/src/plugins/mailbox-alias/mailbox-alias-plugin.c @@ -158,7 +158,7 @@ mailbox_alias_create_symlink(struct mailbox *box, "Mailbox already exists"); return -1; } - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "symlink(%s, %s) failed: %m", fname, new_path); return -1; } diff --git a/src/plugins/quota/quota-storage.c b/src/plugins/quota/quota-storage.c index fcc3147ef6..1211aec9c2 100644 --- a/src/plugins/quota/quota-storage.c +++ b/src/plugins/quota/quota-storage.c @@ -63,7 +63,7 @@ static void quota_set_storage_error(struct quota_transaction_context *qt, break; case QUOTA_ALLOC_RESULT_TEMPFAIL: case QUOTA_ALLOC_RESULT_BACKGROUND_CALC: - mail_storage_set_critical(storage, "quota: %s", internal_err); + mailbox_set_critical(box, "quota: %s", internal_err); break; case QUOTA_ALLOC_RESULT_OK: i_unreached(); diff --git a/src/plugins/virtual/virtual-config.c b/src/plugins/virtual/virtual-config.c index e1390c27ab..f3b020322b 100644 --- a/src/plugins/virtual/virtual-config.c +++ b/src/plugins/virtual/virtual-config.c @@ -477,16 +477,16 @@ int virtual_config_read(struct virtual_mailbox *mbox) fd = open(path, O_RDONLY); if (fd == -1) { if (errno == EACCES) { - mail_storage_set_critical(storage, "%s", + mailbox_set_critical(&mbox->box, "%s", mail_error_eacces_msg("open", path)); } else if (errno != ENOENT) { - mail_storage_set_critical(storage, - "open(%s) failed: %m", path); + mailbox_set_critical(&mbox->box, + "open(%s) failed: %m", path); } else if (errno == ENOENT) { mail_storage_set_error(storage, MAIL_ERROR_NOTFOUND, T_MAIL_ERR_MAILBOX_NOT_FOUND(mbox->box.vname)); } else { - mail_storage_set_critical(storage, + mailbox_set_critical(&mbox->box, "stat(%s) failed: %m", box_path); } return -1; @@ -508,18 +508,18 @@ int virtual_config_read(struct virtual_mailbox *mbox) else ret = virtual_config_parse_line(&ctx, line, &error); if (ret < 0) { - mail_storage_set_critical(storage, - "%s: Error at line %u: %s", - path, linenum, error); + mailbox_set_critical(&mbox->box, + "%s: Error at line %u: %s", + path, linenum, error); break; } } if (ret == 0) { ret = virtual_config_add_rule(&ctx, &error); if (ret < 0) { - mail_storage_set_critical(storage, - "%s: Error at line %u: %s", - path, linenum, error); + mailbox_set_critical(&mbox->box, + "%s: Error at line %u: %s", + path, linenum, error); } } @@ -527,12 +527,12 @@ int virtual_config_read(struct virtual_mailbox *mbox) if (ret == 0 && ctx.have_wildcards) { ret = virtual_config_expand_wildcards(&ctx, &error); if (ret < 0) - mail_storage_set_critical(storage, "%s: %s", path, error); + mailbox_set_critical(&mbox->box, "%s: %s", path, error); } if (ret == 0 && !ctx.have_mailbox_defines) { - mail_storage_set_critical(storage, - "%s: No mailboxes defined", path); + mailbox_set_critical(&mbox->box, + "%s: No mailboxes defined", path); ret = -1; } if (ret == 0) diff --git a/src/plugins/virtual/virtual-storage.c b/src/plugins/virtual/virtual-storage.c index ac98a78afa..3ee7735261 100644 --- a/src/plugins/virtual/virtual-storage.c +++ b/src/plugins/virtual/virtual-storage.c @@ -487,7 +487,7 @@ static int virtual_mailbox_open(struct mailbox *box) int ret = 0; if (virtual_mailbox_is_in_open_stack(mbox->storage, box->name)) { - mail_storage_set_critical(box->storage, + mailbox_set_critical(box, "Virtual mailbox loops: %s", box->name); return -1; } @@ -530,9 +530,8 @@ static int virtual_mailbox_open(struct mailbox *box) mail_index_update_header_ext(t, mbox->virtual_guid_ext_id, 0, mbox->guid, GUID_128_SIZE); if (mail_index_transaction_commit(&t) < 0) { - mail_storage_set_critical(box->storage, - "Cannot write GUID for virtual mailbox %s to index", - mailbox_get_vname(box)); + mailbox_set_critical(box, + "Cannot write GUID for virtual mailbox to index"); virtual_mailbox_close_internal(mbox); index_storage_mailbox_close(box); return -1; @@ -606,9 +605,8 @@ static int virtual_storage_set_have_guid_flags(struct virtual_mailbox *mbox) since this could be called from mailbox_get_open_status() and it would panic. So just log the error and skip the mailbox. */ - mail_storage_set_critical(mbox->box.storage, - "Virtual mailbox %s: Failed to get have_guid existence for backend mailbox %s: %s", - mailbox_get_vname(&mbox->box), + mailbox_set_critical(&mbox->box, + "Virtual mailbox: Failed to get have_guid existence for backend mailbox %s: %s", mailbox_get_vname(bboxes[i]->box), errstr); continue; } @@ -666,8 +664,7 @@ virtual_mailbox_get_metadata(struct mailbox *box, i_assert(box->opened); if ((items & MAILBOX_METADATA_GUID) != 0) { if (guid_128_is_empty(mbox->guid)) { - mail_storage_set_critical(box->storage, "GUID missing for virtual folder %s", - mailbox_get_vname(box)); + mailbox_set_critical(box, "GUID missing for virtual folder"); return -1; } guid_128_copy(metadata_r->guid, mbox->guid); diff --git a/src/plugins/zlib/zlib-plugin.c b/src/plugins/zlib/zlib-plugin.c index 36c9a3055d..5a9d0cb18d 100644 --- a/src/plugins/zlib/zlib-plugin.c +++ b/src/plugins/zlib/zlib-plugin.c @@ -143,7 +143,7 @@ static int zlib_istream_opened(struct mail *_mail, struct istream **stream) handler = compression_detect_handler(*stream); if (handler != NULL) { if (handler->create_istream == NULL) { - mail_storage_set_critical(_mail->box->storage, + mail_set_critical(_mail, "zlib plugin: Detected %s compression " "but support not compiled in", handler->ext); return -1;