From 826f16c0cd4c1ea667a441f45caf48e913bac906 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 28 Apr 2016 12:47:02 +0300 Subject: [PATCH] lib-fs: Fixed multiple concurrent fs_read_stream() calls Return a new limit-istream, so each istream can have its own independent offset. --- src/lib-fs/fs-api.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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);