]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-fs: Fixes to previous fs_write_stream_abort*() changes.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 23 Aug 2016 10:41:38 +0000 (13:41 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 23 Aug 2016 10:41:38 +0000 (13:41 +0300)
src/lib-fs/fs-api.c
src/lib-fs/fs-randomfail.c

index 585abbccf87f6de4b1f92df1144010b9af263017..86bc0843f3c7c18460aec5ee12d3a0e2582acbd1 100644 (file)
@@ -746,7 +746,7 @@ void fs_write_stream_abort_error(struct fs_file *file, struct ostream **output,
 void fs_write_stream_abort_parent(struct fs_file *file, struct ostream **output)
 {
        i_assert(file->parent != NULL);
-       i_assert(fs_filelast_error(file->parent) != NULL);
+       i_assert(fs_file_last_error(file->parent) != NULL);
        fs_write_stream_abort(file, output);
 }
 
@@ -918,19 +918,19 @@ int fs_default_copy(struct fs_file *src, struct fs_file *dest)
                fs_set_error_async(dest->fs);
                return -1;
        case OSTREAM_SEND_ISTREAM_RESULT_ERROR_INPUT:
-               errno = dest->copy_input->stream_errno;
                fs_write_stream_abort_error(dest, &dest->copy_output,
                                            "read(%s) failed: %s",
                                            i_stream_get_name(dest->copy_input),
                                            i_stream_get_error(dest->copy_input));
+               errno = dest->copy_input->stream_errno;
                i_stream_unref(&dest->copy_input);
                return -1;
        case OSTREAM_SEND_ISTREAM_RESULT_ERROR_OUTPUT:
-               errno = dest->copy_output->stream_errno;
                fs_write_stream_abort_error(dest, &dest->copy_output,
                                            "write(%s) failed: %s",
                                            o_stream_get_name(dest->copy_output),
                                            o_stream_get_error(dest->copy_output));
+               errno = dest->copy_output->stream_errno;
                i_stream_unref(&dest->copy_input);
                return -1;
        }
index a1593290e64a105c99a8859c48d4e49586bd5b2d..24abcc19a9ce92be8d8a1bc180ce039eecb0e874 100644 (file)
@@ -401,7 +401,11 @@ static int fs_randomfail_write_stream_finish(struct fs_file *_file, bool success
                        _file->output = NULL;
                else
                        o_stream_unref(&_file->output);
-               if (!success || fs_random_fail(_file->fs, 1, FS_OP_WRITE)) {
+               if (!success) {
+                       fs_write_stream_abort_parent(_file->parent, &file->super_output);
+                       return -1;
+               }
+               if (!fs_random_fail(_file->fs, 1, FS_OP_WRITE)) {
                        fs_write_stream_abort_error(file->super, &file->super_output, RANDOMFAIL_ERROR);
                        return -1;
                }