]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fs-posix: fs_read_stream() now returns an istream that can live even after the fs_fil...
authorTimo Sirainen <tss@iki.fi>
Wed, 24 Sep 2014 23:55:34 +0000 (02:55 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 24 Sep 2014 23:55:34 +0000 (02:55 +0300)
src/lib-fs/fs-posix.c

index 25bbd79c48d69af76be339c0a7cb6785301599c7..c2ce8fb6dbcf1b690b824c3654957d8a9053b7e9 100644 (file)
@@ -350,10 +350,11 @@ fs_posix_read_stream(struct fs_file *_file, size_t max_buffer_size)
 
        if (file->fd == -1 && fs_posix_open(file) < 0)
                input = i_stream_create_error_str(errno, "%s", fs_last_error(_file->fs));
-       else
-               input = i_stream_create_fd(file->fd, max_buffer_size, FALSE);
+       else {
+               /* the stream could live even after the fs_file */
+               input = i_stream_create_fd_autoclose(&file->fd, max_buffer_size);
+       }
        i_stream_set_name(input, _file->path);
-       i_stream_add_destroy_callback(input, fs_posix_file_close, _file);
        return input;
 }