]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: istream-seekable - Change stream to be blocking=TRUE after reaching EOF
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 19 Feb 2019 08:17:45 +0000 (10:17 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Wed, 20 Feb 2019 12:03:32 +0000 (14:03 +0200)
After EOF is reached, the stream is now fully read into file or memory.
read()s can no longer return 0, so blocking=TRUE can be used.

Some callers were reusing the seekable stream in places that required
blocking=TRUE.

Fixes at least with imapsieve vnd.dovecot report extension:
Panic: file ostream.c: line 427 (o_stream_nsend_istream): assertion failed: (instream->blocking)

src/lib/istream-seekable.c

index 875bba667f25884b50db81552630828633b2a7da..67ff65620b72576ae0971287b5e52c22589d5673 100644 (file)
@@ -164,6 +164,10 @@ static ssize_t read_more(struct seekable_istream *sstream)
                        /* last one, EOF */
                        sstream->size = sstream->istream.istream.v_offset;
                        sstream->istream.istream.eof = TRUE;
+                       /* Now that EOF is reached, the stream can't return 0
+                          anymore. Callers can now use this stream in places
+                          that assert that blocking==TRUE. */
+                       sstream->istream.istream.blocking = TRUE;
                        unref_streams(sstream);
                        return -1;
                }