From: Timo Sirainen Date: Wed, 24 Sep 2014 23:55:34 +0000 (+0300) Subject: fs-posix: fs_read_stream() now returns an istream that can live even after the fs_fil... X-Git-Tag: 2.2.14.rc1~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96c5e558bbbcd09eb7cb160077fa1f00ae4e5131;p=thirdparty%2Fdovecot%2Fcore.git fs-posix: fs_read_stream() now returns an istream that can live even after the fs_file is closed. --- diff --git a/src/lib-fs/fs-posix.c b/src/lib-fs/fs-posix.c index 25bbd79c48..c2ce8fb6db 100644 --- a/src/lib-fs/fs-posix.c +++ b/src/lib-fs/fs-posix.c @@ -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; }