]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Use mail_set_critical() and mailbox_set_critical() if possible
authorMartti Rannanjärvi <martti.rannanjarvi@dovecot.fi>
Mon, 27 Nov 2017 12:19:34 +0000 (14:19 +0200)
committerMartti Rannanjärvi <martti.rannanjarvi@dovecot.fi>
Mon, 11 Dec 2017 07:57:18 +0000 (09:57 +0200)
Replace calls to mail_storage_set_critical() with mail_set_critical()
or mailbox_set_critical() in places where mailbox or mail are easily
available.

69 files changed:
src/imap/cmd-append.c
src/imap/imap-fetch-body.c
src/lib-imap-storage/imap-msgpart.c
src/lib-storage/index/cydir/cydir-mail.c
src/lib-storage/index/cydir/cydir-save.c
src/lib-storage/index/cydir/cydir-storage.c
src/lib-storage/index/dbox-common/dbox-save.c
src/lib-storage/index/dbox-common/dbox-storage.c
src/lib-storage/index/dbox-multi/mdbox-mail.c
src/lib-storage/index/dbox-multi/mdbox-save.c
src/lib-storage/index/dbox-multi/mdbox-storage.c
src/lib-storage/index/dbox-multi/mdbox-sync.c
src/lib-storage/index/dbox-single/sdbox-copy.c
src/lib-storage/index/dbox-single/sdbox-file.c
src/lib-storage/index/dbox-single/sdbox-mail.c
src/lib-storage/index/dbox-single/sdbox-save.c
src/lib-storage/index/dbox-single/sdbox-storage.c
src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c
src/lib-storage/index/dbox-single/sdbox-sync.c
src/lib-storage/index/imapc/imapc-mail-fetch.c
src/lib-storage/index/imapc/imapc-mail.c
src/lib-storage/index/imapc/imapc-save.c
src/lib-storage/index/imapc/imapc-search.c
src/lib-storage/index/imapc/imapc-storage.c
src/lib-storage/index/imapc/imapc-sync.c
src/lib-storage/index/index-attachment.c
src/lib-storage/index/index-attribute.c
src/lib-storage/index/index-mail-binary.c
src/lib-storage/index/index-mail.c
src/lib-storage/index/index-mailbox-size.c
src/lib-storage/index/index-search.c
src/lib-storage/index/index-sort-string.c
src/lib-storage/index/index-storage.c
src/lib-storage/index/index-sync-pvt.c
src/lib-storage/index/index-sync.c
src/lib-storage/index/index-thread.c
src/lib-storage/index/index-transaction.c
src/lib-storage/index/maildir/maildir-copy.c
src/lib-storage/index/maildir/maildir-keywords.c
src/lib-storage/index/maildir/maildir-mail.c
src/lib-storage/index/maildir/maildir-save.c
src/lib-storage/index/maildir/maildir-storage.c
src/lib-storage/index/maildir/maildir-sync-index.c
src/lib-storage/index/maildir/maildir-sync.c
src/lib-storage/index/maildir/maildir-uidlist.c
src/lib-storage/index/maildir/maildir-util.c
src/lib-storage/index/mbox/mbox-file.c
src/lib-storage/index/mbox/mbox-lock.c
src/lib-storage/index/mbox/mbox-mail.c
src/lib-storage/index/mbox/mbox-storage.c
src/lib-storage/index/mbox/mbox-sync-list-index.c
src/lib-storage/index/mbox/mbox-sync-rewrite.c
src/lib-storage/index/mbox/mbox-sync.c
src/lib-storage/index/pop3c/pop3c-storage.c
src/lib-storage/index/pop3c/pop3c-sync.c
src/lib-storage/index/raw/raw-mail.c
src/lib-storage/index/raw/raw-storage.c
src/lib-storage/list/mailbox-list-index-backend.c
src/lib-storage/mail-copy.c
src/lib-storage/mail-storage.c
src/lib-storage/mailbox-recent-flags.c
src/plugins/acl/acl-mailbox.c
src/plugins/fts/fts-storage.c
src/plugins/lazy-expunge/lazy-expunge-plugin.c
src/plugins/mailbox-alias/mailbox-alias-plugin.c
src/plugins/quota/quota-storage.c
src/plugins/virtual/virtual-config.c
src/plugins/virtual/virtual-storage.c
src/plugins/zlib/zlib-plugin.c

index a630b9c8de06508653842ec4983d5de4a6cbea71..ecb48623afcef64928e3515839597ce74de122a6 100644 (file)
@@ -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);
index ebe42b31f3989c49a3acabe091623505355ce365..3711dd5520cb4748e2afdd77a5309449c30337f4 100644 (file)
@@ -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";
 }
 
index 84e0773a9a745ffb67d01788ccbdd3594269283e..a92f39df3740822ce1f3affa992ae54b27971208 100644 (file)
@@ -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);
index cbac6956a494c3090466cba876aaf52cbd06bca0..49d8f17c4754fcc8cdc84461a327e72396dcca9c 100644 (file)
@@ -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;
                }
index 323c4e30131154603db122adbf961d0acd8d9355..5aaf14c2829cff39c747c960bd1b6bc163632f97 100644 (file)
@@ -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;
index eec578abb5f4472590ddaa6f775a0e47991d13ba..7843cff38886730c170ddfb5a0eba07ff13c5a5c 100644 (file)
@@ -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)
index 91424c8e2bd9ccce4fd1c778f79daec1f6035505..646d1df915047159a32b41a8f1b63f7999f754cc 100644 (file)
@@ -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) {
index 6eff972a0a899c4c51ddcec7d9e55c343d9ff355..05f3f9524653554c451711254218601980f84a0f 100644 (file)
@@ -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;
                }
index 1a13b41f8518566e543335f1e3f1ac7297dcf57f..f93d0a756c83d42717d7cca5823e088edef7d122 100644 (file)
@@ -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;
        }
index f5ba8699417f56a2dd5ab302b1d673277abddd23..aa9a665d82611fcb038abd0c16d5dae17c1d693d 100644 (file)
@@ -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);
                }
        }
index c1826bb386d0c3f816602964963042ad199ba414..b0951ae2057bc7c1781ed9816ae3b7a9b997ebc8 100644 (file)
@@ -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;
        }
index 27ceb0add24508ad2a7cd12ba65f141c4d407bf7..aaaa4e9f9b21bf4c46ee8083e9079e7b8442cc3c 100644 (file)
@@ -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);
index f21358ed3943b0528f5d2cc7dbcd3a7ebcf887a9..3210c09500dbebe9394da8fe7fb6bad000ecc448 100644 (file)
@@ -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);
index 1256e12f73d0f3d7d0b6a05ee5e2230f0676b958..48754a10e264d0939bfb736daa7f8364f12d08f7 100644 (file)
@@ -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);
                }
index 7702d80ff769ceb43d430b87c96551fcd782e46c..62cac9ef16cd886531983c2594b2cbcad0d364db 100644 (file)
@@ -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;
                }
index 4a3333650bdd5cfa05b9061c027c2944a9229793..03cd3a4e2927620b8e9df70c9881404802858add 100644 (file)
@@ -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);
                }
        }
index 57f43a9aab7bf3ff9f3d7eb681388b8285bd00d4..f49f5acf64199c3a484e5e5b3a1e5f8c86e237d7 100644 (file)
@@ -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,
index 317253136ccfff7b10f503d24f3bc039eee6775d..e773f3aa70b74c07d7a022e8498263650afb63af 100644 (file)
@@ -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;
        }
 
index ba6f9d2c70b44d8cb220ca94caabbdd039811f30..7ded78da6df47ebd395416c4d874a140e9af2b4a 100644 (file)
@@ -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. */
index cfb11fdc421353e4d2d02ad65fb1569d81c574ce..e6c1c9f368d45c0642093dbb77a69b381e89e7c5 100644 (file)
@@ -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 {
index 87645dd64be73f30b159049e7ce798f331c1b05f..2b9146b705bd3240a5dc3df37721f52528234250 100644 (file)
@@ -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;
                }
index 59e8dd66abae5ae2fe22700915832db2beec107a..1633cea310970108acc901199c966ec7ac6cc3b8 100644 (file)
@@ -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;
        }
index 13b223edb3ff6e32a94d8d363f681c9001d17e68..57427f68f9b780684010731d81702b48dbc50823 100644 (file)
@@ -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);
index 6979d82e79c9b3a069c25d560da1c6fcd9774e49..080f73eaaa91bc314c3a8ecd801427b481f24be0 100644 (file)
@@ -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);
index 4cda5e0552764a4cb4948a7cf8f2afe7a48dae45..0ef3f14c9a91c1a9415864838eb91806baa22136 100644 (file)
@@ -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;
index 2ed6da8af6857bb51472d5384a8c4d3e2d274e93..d54dcefcef1a600cb1be6438c1443dfb7de65413 100644 (file)
@@ -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;
index 6168f8da5291c050074a7d6e6aa8416be2cd2d96..ae92ebe97b8db1e69ced8926ae028d9f0fd5520f 100644 (file)
@@ -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);
                }
index 32df0670cbf0f1f50650449a11e7dadba64f97b5..b16a80aac641146df6bf659230b0775487251449 100644 (file)
@@ -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);
index d01b65dfc19d7f67a4e2bab4c64a4e202ff14018..e6f73b12cf9212fafc691442d0368d3b6c9692fa 100644 (file)
@@ -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",
index 37f03da6d324f392829c9041213830524bc381a3..40806f9b9aec6db9107c975c9be6449b21fe8f81 100644 (file)
@@ -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;
index 36791fb050997274394ff88a286e1814f5d12ceb..96fae0da9b5d32b5ad9e59112b070f364781ad82 100644 (file)
@@ -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));
index 8ebc0866e9db7007008353c235c7c1d95ee11a21..990ab235c49103290b1c4cf0d1bb234bfb403fb8 100644 (file)
@@ -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,
index b10f0c3c29f7bc7b8eecc41847eaa8ddc06cfc5c..2155538fba5b9f51f6ace86c138aef05815c14c9 100644 (file)
@@ -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);
index 530052ce85caea0451850020e8c7dbaa11efbb70..6b9d407dddb4742abf787bd8bceeddbf09666906 100644 (file)
@@ -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;
index 5b029aad0374e879d5edc760ebe4ac2d46e629dc..742909e7f6302fe9bf1ccae5bce70452fc006157 100644 (file)
@@ -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;
        }
 
index 26733779e2ec863a27211cd0a5b41796365d477a..5e2baf4714e0f94e586e24b19f77780192a17ad0 100644 (file)
@@ -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;
index 92b1796e92dd13634d158518a71a0fbdf5b8dd4a..d67bd1bb4c70be020587d21cd12200244fb46c96 100644 (file)
@@ -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;
                }
index 0cc0f3581218d03b6c7a7074c3bd8f69627151ba..8b13844049e69f18a805c9470b82ad9439753586 100644 (file)
@@ -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;
        }
 
index c8d7aa4119b5efc84bd3284a3febf0d53935cbbe..6dbd09e32150eb8b397f84545321ca50adda9782 100644 (file)
@@ -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;
        }
index 7bf049d147631a276ed148832a95b87bf81d80cd..e7812da6ae518a711d77d98d8c6a140a71714668 100644 (file)
@@ -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;
 }
 
index 0f6e1e341a027bc904b171c011eb0d52ca97703e..0d7d1dc5c8a77c8b79282e06e8eabaf7761b4de2 100644 (file)
@@ -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;
                }
index 01859e7bbf31eb99a842b92f28292ad9b764cb1e..388128b40b33442e3abeaf56cdd89cd9304fbf00 100644 (file)
@@ -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);
index 413871117cc041c21acc13e00e70bd97015e8938..f7f098a9586a8205f2dde9c5a00b285ca8160da5 100644 (file)
@@ -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)
index c3721ec75654ede7c1cf6681c071e8104bd25683..8951cd78a85aa8a4eae91279788e8da94d0c2386 100644 (file)
@@ -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;
        }
 
index be9b1f09d9ece00dab4e5a0a8cd77652b26e21ca..87684757e90b76372517da15e9e8c11a8cca4b59 100644 (file)
@@ -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;
index 1233bfc41166490a0de21eeb953f3e299d472382..488e9333154b9801467fde4345ad967af7f744a4 100644 (file)
@@ -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;
index 10112f7ae945235f3140c73b3c2a1f9e35ef328d..130808f04681b126e26d6da7ffa164155667d72b 100644 (file)
@@ -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;
index 7542241cfecb5e3ea885d783d902fc942fa858d1..e97d7242c1771c350b509027543f23bad23e0b3f 100644 (file)
@@ -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));
index 0ee2c729fa42260d025b64aacc99a4180ff83bcc..10839c97f2bdcb671f093e673c9085939a370685 100644 (file)
@@ -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);
index f761011007d2d8a95ceb56f46a965ccfff0884fb..2a35a518b5352b2e9f8ac0fbdca7f9c33c6444ca 100644 (file)
@@ -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;
        }
index 9f499aa72825718d135abe9f03cafdd30b68dc8a..84e3c836e053c908cc6990062ee238c9d6d943e0 100644 (file)
@@ -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 ||
index a15f3f54d23457b4675f007076b54b103f3a39f7..fd4f3e073c3be67b7779ceb79752049098a1d038 100644 (file)
@@ -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,
index afcbbf0087c70bb197b4e0c4fc908797f41f018f..cb36f835d858048c6b4f1552817d44ead9f22119 100644 (file)
@@ -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;
                        }
index 4928939046fa531667ec3ca125c168564d425637..62d7223de72afcdce44e9349db1fb7d06761af85 100644 (file)
@@ -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;
        }
index edfe91fc6a2a5a8118bf304e4d46950e6a58f1ce..868b148371f9b3da96776cebfb54068a58d7cd11 100644 (file)
@@ -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;
                }
index 79ab8f3ae79620366a3ab59ccc7f94d0387e79f3..8e8d84d065d1ba26bdf2d52a936e1a0e41fb0014 100644 (file)
@@ -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;
        }
 
index d1f3147007675d619477a8f22ee5ad0480e32c0c..32f578c7c1e06d85f8e8f70c2a95bf3ad2d30de2 100644 (file)
@@ -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;
        }
index 2744a724873e996d9a6c9f1f0183c461e81cae1a..44cebec08c8de2bfbb281f35af56ceec3caab9ce 100644 (file)
@@ -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;
                }
        }
index 2d344ad518331ebd0aa8f2b3fd40225301907af8..39a8fa3625e510bf9e2595c7919f7bd344f34b8c 100644 (file)
@@ -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;
index e20c79d54728c40dc5950f952576cfd0e04b128d..b0134d5c460db29ef9af17e2756df1a3f289416a 100644 (file)
@@ -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;
        }
 }
index 6b269c72a6f42a25050fd71c4298251a73dcaeab..b8d58b3efce12ca0252b5235f9e58dd81ac59c0a 100644 (file)
@@ -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;
        }
index 4efcc0f10399d7433654e241b6576913a2adf582..732a5d0fbae5c51ee4de91dac8e2b5511a94c782 100644 (file)
@@ -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;
        }
 
index 4a04b2b20cbd35c465585320577dfd7b9c367d49..ee8e6d948ef5d68f9be77906483e7d37e5d01a4e 100644 (file)
@@ -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;
                }
        }
index b1e8b593ba4af9d04202025de1d2308bb17b336f..10acd567cf164543e23c6a9bda13d464c019091f 100644 (file)
@@ -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(&lt->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);
index 5c4474310d89980628f4e55e63db8ffbe2f84ec1..77667dd4ab71e73d53d9a85f112754acbda87405 100644 (file)
@@ -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;
        }
index fcc3147ef6d9e731cee126bd2d07d20a2d555537..1211aec9c2b5e059ccbcd67197c1af69c5ebe4dc 100644 (file)
@@ -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();
index e1390c27ab631a021d2dc1fe29a626747f6ff4f6..f3b020322b60da92221406cbbb8e5f82dac8426f 100644 (file)
@@ -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)
index ac98a78afa63cd01d8e23f16b764ac69e0433353..3ee7735261d1511d143d8e786781b01ff9bf1574 100644 (file)
@@ -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);
index 36c9a3055de6fbc89b53dd91e9a7b57a38d24624..5a9d0cb18d5cc88ce7391323fee7649a639d769e 100644 (file)
@@ -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;