]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dbox: iostream error logging improvements.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 16 May 2016 12:22:11 +0000 (15:22 +0300)
committerGitLab <gitlab@git.dovecot.net>
Wed, 18 May 2016 12:21:30 +0000 (15:21 +0300)
src/lib-storage/index/dbox-common/dbox-file-fix.c
src/lib-storage/index/dbox-common/dbox-save.c

index 1335d484f128c1c5b26158c688b94a098383c7c5..0140c085c8c2f331aa569e1ff75acf99040f63ba 100644 (file)
@@ -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;
index c62973874cdfc53c59b7406a91b48444a6bed119..5128c341e9ea7471d4e6fed2a5b92dd3f103c56b 100644 (file)
@@ -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) {