]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Fix i_stream_set_input_pending() when IO is set later
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 22 Jan 2019 10:59:57 +0000 (12:59 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Thu, 21 Mar 2019 08:02:48 +0000 (10:02 +0200)
After i_stream_set_io() is called to set the IO, it should already be marked
as pending.

This fixes at least running imaptest with SSL.

src/lib/istream-private.h
src/lib/istream.c

index b9329f7337ab6a17f9f367c44483c26d8d74adf4..92439cd33af0dc17a4b8e72fc6a406f3ad6a65fa 100644 (file)
@@ -67,6 +67,7 @@ struct istream_private {
        bool return_nolf_line:1;
        bool stream_size_passthrough:1; /* stream is parent's size */
        bool nonpersistent_buffers:1;
+       bool io_pending:1;
 };
 
 struct istream_snapshot {
index d3333f9f94e611bdde6e68c2ebd44f22c1108797..bc5f9e011bc8aca83b9f1acbfdc055d29b67218c 100644 (file)
@@ -931,6 +931,8 @@ void i_stream_set_input_pending(struct istream *stream, bool pending)
        stream = i_stream_get_root_io(stream);
        if (stream->real_stream->io != NULL)
                io_set_pending(stream->real_stream->io);
+       else
+               stream->real_stream->io_pending = TRUE;
 }
 
 void i_stream_switch_ioloop_to(struct istream *stream, struct ioloop *ioloop)
@@ -957,6 +959,10 @@ void i_stream_set_io(struct istream *stream, struct io *io)
 
        i_assert(stream->real_stream->io == NULL);
        stream->real_stream->io = io;
+       if (stream->real_stream->io_pending) {
+               io_set_pending(io);
+               stream->real_stream->io_pending = FALSE;
+       }
 }
 
 void i_stream_unset_io(struct istream *stream, struct io *io)