]> 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, 28 Apr 2016 09:48:12 +0000 (12:48 +0300)
Return a new limit-istream, so each istream can have its own independent
offset.

src/lib-fs/fs-api.c

index aa5002ced1823617fce4d5765701d7811fec60a1..b947a8f1d1be569d882af808535dad4a1b65d2cd 100644 (file)
@@ -521,9 +521,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;
        }
        i_assert(!file->istream_open);
        T_BEGIN {