]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fixed istream error handling while saving mails.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 10 May 2016 21:09:02 +0000 (17:09 -0400)
committerGitLab <gitlab@git.dovecot.net>
Thu, 12 May 2016 22:07:36 +0000 (01:07 +0300)
We might have logged them as write errors, or we might have ignored the
error if i_stream_read() failed. Now the behavior is consistent.

src/lib-storage/index/index-storage.c

index e94b82a3e14e789bc86b8be59f9bab5b6c4a2026..c0a93b6ac9fa59f70dab79d456457b9b792f201f 100644 (file)
@@ -1026,10 +1026,13 @@ int index_storage_save_continue(struct mail_save_context *ctx,
 
        do {
                if (o_stream_send_istream(ctx->data.output, input) < 0) {
+                       if (input->stream_errno != 0)
+                               break;
                        if (!mail_storage_set_error_from_errno(storage)) {
                                mail_storage_set_critical(storage,
-                                       "write(%s) failed: %m",
-                                       o_stream_get_name(ctx->data.output));
+                                       "save: write(%s) failed: %s",
+                                       o_stream_get_name(ctx->data.output),
+                                       o_stream_get_error(ctx->data.output));
                        }
                        return -1;
                }
@@ -1040,5 +1043,11 @@ int index_storage_save_continue(struct mail_save_context *ctx,
                   input stream. we'll have to make sure we don't return with
                   one of the streams still having data in them. */
        } while (i_stream_read(input) > 0);
+
+       if (input->stream_errno != 0) {
+               mail_storage_set_critical(storage, "save: read(%s) failed: %s",
+                       i_stream_get_name(input), i_stream_get_error(input));
+               return -1;
+       }
        return 0;
 }