Skip to content

Commit

Permalink
lib-fs: Fixed multiple concurrent fs_read_stream() calls
Browse files Browse the repository at this point in the history
Return a new limit-istream, so each istream can have its own independent
offset.
  • Loading branch information
sirainen committed May 12, 2016
1 parent 9f300ec commit 826f16c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib-fs/fs-api.c
Expand Up @@ -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);
Expand Down

0 comments on commit 826f16c

Please sign in to comment.