From: Timo Sirainen Date: Thu, 28 Apr 2016 09:47:02 +0000 (+0300) Subject: lib-fs: Fixed multiple concurrent fs_read_stream() calls X-Git-Tag: 2.2.25.rc1~303 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=826f16c0cd4c1ea667a441f45caf48e913bac906;p=thirdparty%2Fdovecot%2Fcore.git lib-fs: Fixed multiple concurrent fs_read_stream() calls Return a new limit-istream, so each istream can have its own independent offset. --- diff --git a/src/lib-fs/fs-api.c b/src/lib-fs/fs-api.c index ba2d09324e..5247636be6 100644 --- a/src/lib-fs/fs-api.c +++ b/src/lib-fs/fs-api.c @@ -512,9 +512,10 @@ struct istream *fs_read_stream(struct fs_file *file, size_t max_buffer_size) } if (file->seekable_input != NULL) { - i_stream_seek(file->seekable_input, 0); - i_stream_ref(file->seekable_input); - return file->seekable_input; + /* allow multiple open streams, each in a different position */ + input = i_stream_create_limit(file->seekable_input, (uoff_t)-1); + i_stream_seek(input, 0); + return input; } T_BEGIN { input = file->fs->v.read_stream(file, max_buffer_size);