From: Timo Sirainen Date: Mon, 16 May 2016 12:22:11 +0000 (+0300) Subject: dbox: iostream error logging improvements. X-Git-Tag: 2.3.0.rc1~3729 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8acb8deef145fc0225095ed3974b2685fdaf959e;p=thirdparty%2Fdovecot%2Fcore.git dbox: iostream error logging improvements. --- diff --git a/src/lib-storage/index/dbox-common/dbox-file-fix.c b/src/lib-storage/index/dbox-common/dbox-file-fix.c index 1335d484f1..0140c085c8 100644 --- a/src/lib-storage/index/dbox-common/dbox-file-fix.c +++ b/src/lib-storage/index/dbox-common/dbox-file-fix.c @@ -234,31 +234,31 @@ stream_copy(struct dbox_file *file, struct ostream *output, { struct istream *input; off_t bytes; + int ret = 0; input = i_stream_create_limit(file->input, count); bytes = o_stream_send_istream(output, input); - errno = input->stream_errno; - i_stream_unref(&input); - if (errno != 0) { + if (input->stream_errno != 0) { mail_storage_set_critical(&file->storage->storage, - "read(%s) failed: %m", file->cur_path); - return -1; - } - if (o_stream_nfinish(output) < 0) { + "read(%s) failed: %s", file->cur_path, + i_stream_get_error(input)); + ret = -1; + } else if (o_stream_nfinish(output) < 0) { mail_storage_set_critical(&file->storage->storage, - "write(%s) failed: %m", out_path); - return -1; - } - i_assert(bytes >= 0); - if ((uoff_t)bytes != count) { + "write(%s) failed: %s", out_path, + o_stream_get_error(output)); + ret = -1; + } else if ((uoff_t)bytes != count) { + i_assert(bytes >= 0); mail_storage_set_critical(&file->storage->storage, "o_stream_send_istream(%s) copied only %" PRIuUOFF_T" of %"PRIuUOFF_T" bytes", out_path, bytes, count); - return -1; + ret = -1; } - return 0; + i_stream_unref(&input); + return ret; } static void dbox_file_skip_broken_header(struct dbox_file *file) @@ -409,9 +409,9 @@ dbox_file_fix_write_stream(struct dbox_file *file, uoff_t start_offset, ret = message_get_body_size(body_input, &body, &has_nuls); i_stream_unref(&body_input); if (ret < 0) { - errno = body_input->stream_errno; mail_storage_set_critical(&file->storage->storage, - "read(%s) failed: %m", file->cur_path); + "read(%s) failed: %s", file->cur_path, + i_stream_get_error(body_input)); return -1; } @@ -440,7 +440,7 @@ dbox_file_fix_write_stream(struct dbox_file *file, uoff_t start_offset, } if (o_stream_nfinish(output) < 0) { mail_storage_set_critical(&file->storage->storage, - "write(%s) failed: %m", temp_path); + "write(%s) failed: %s", temp_path, o_stream_get_error(output)); ret = -1; } return ret; diff --git a/src/lib-storage/index/dbox-common/dbox-save.c b/src/lib-storage/index/dbox-common/dbox-save.c index c62973874c..5128c341e9 100644 --- a/src/lib-storage/index/dbox-common/dbox-save.c +++ b/src/lib-storage/index/dbox-common/dbox-save.c @@ -57,8 +57,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: %m", - o_stream_get_name(ctx->dbox_output)); + mail_storage_set_critical(_storage, "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; @@ -99,8 +100,9 @@ void dbox_save_end(struct dbox_save_context *ctx) } if (o_stream_nfinish(mdata->output) < 0) { mail_storage_set_critical(ctx->ctx.transaction->box->storage, - "write(%s) failed: %m", - o_stream_get_name(mdata->output)); + "write(%s) failed: %s", + o_stream_get_name(mdata->output), + o_stream_get_error(mdata->output)); ctx->failed = TRUE; } if (mdata->output != dbox_output) {