]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-fs: Call o_stream_nfinish() automatically for all backends in fs_write_stream_fin...
authorTimo Sirainen <tss@iki.fi>
Wed, 17 Jun 2015 09:21:52 +0000 (12:21 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 17 Jun 2015 09:21:52 +0000 (12:21 +0300)
Otherwise each backend needs to do it internally. fs-metawrap for example
was missing this and causing assert-crashes.

src/lib-fs/fs-api.c

index 88b355d3d090bfa67eb870c5512495062983598b..f1b6965afa01601c8eee60dd8dfac370e0cfb730 100644 (file)
@@ -557,14 +557,23 @@ struct ostream *fs_write_stream(struct fs_file *file)
 int fs_write_stream_finish(struct fs_file *file, struct ostream **output)
 {
        int ret;
+       bool success = TRUE;
 
        i_assert(*output == file->output || *output == NULL);
 
        *output = NULL;
        if (file->output != NULL)
                o_stream_uncork(file->output);
+       if (file->output != NULL) {
+               if (o_stream_nfinish(file->output) < 0) {
+                       fs_set_error(file->fs, "write(%s) failed: %s",
+                                    o_stream_get_name(file->output),
+                                    o_stream_get_error(file->output));
+                       success = FALSE;
+               }
+       }
        T_BEGIN {
-               ret = file->fs->v.write_stream_finish(file, TRUE);
+               ret = file->fs->v.write_stream_finish(file, success);
        } T_END;
        if (ret != 0)
                file->metadata_changed = FALSE;