From b197576494e66796ac393a90fe57ae1c12f00b2e Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 22 Jan 2019 12:59:57 +0200 Subject: [PATCH] lib: Fix i_stream_set_input_pending() when IO is set later 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 | 1 + src/lib/istream.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/lib/istream-private.h b/src/lib/istream-private.h index b9329f7337..92439cd33a 100644 --- a/src/lib/istream-private.h +++ b/src/lib/istream-private.h @@ -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 { diff --git a/src/lib/istream.c b/src/lib/istream.c index d3333f9f94..bc5f9e011b 100644 --- a/src/lib/istream.c +++ b/src/lib/istream.c @@ -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) -- 2.47.3