]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-fs: Fixed multiple concurrent fs_read_stream() calls
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 28 Apr 2016 09:47:02 +0000 (12:47 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 12 May 2016 17:33:46 +0000 (13:33 -0400)
Return a new limit-istream, so each istream can have its own independent
offset.

src/lib-fs/fs-api.c

index ba2d09324ea8aa5d14ff2f11c90d1790f39c4f32..5247636be6e09c8e279605a9671659d0bc85a27a 100644 (file)
@@ -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);