]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: istream-multiplex - Forward i_stream_switch_ioloop() to parent
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 9 Oct 2017 10:14:23 +0000 (13:14 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 9 Oct 2017 10:14:23 +0000 (13:14 +0300)
Most istreams do this because istream_private.parent is set to the parent
stream, but this can't be done with istream-multiplex. The main problem
with attempting to do the same with istream-multiplex is that the different
channels don't share the same I/O. Just because one channel received data
doesn't mean that other channels received any data. (It would be possible
to solve this by implementing a new method that allows overriding
i_stream_set_io(), but I'm not sure if that's a good idea either.)

src/lib/istream-multiplex.c

index 6a5f0eabe55fb5d9e673654a68a810c3ea0a8696..6c11467ca24c0af8e541d6c17be5d29d8f3b6916 100644 (file)
@@ -181,6 +181,14 @@ static ssize_t i_stream_multiplex_ichannel_read(struct istream_private *stream)
        return i_stream_multiplex_read(channel->mstream, channel->cid);
 }
 
+static void
+i_stream_multiplex_ichannel_switch_ioloop(struct istream_private *stream)
+{
+       struct multiplex_ichannel *channel = (struct multiplex_ichannel*)stream;
+
+       i_stream_switch_ioloop(channel->mstream->parent);
+}
+
 static void
 i_stream_multiplex_ichannel_close(struct iostream_private *stream, bool close_parent)
 {
@@ -229,6 +237,7 @@ i_stream_add_channel_real(struct multiplex_istream *mstream, uint8_t cid)
        channel->cid = cid;
        channel->mstream = mstream;
        channel->istream.read = i_stream_multiplex_ichannel_read;
+       channel->istream.switch_ioloop = i_stream_multiplex_ichannel_switch_ioloop;
        channel->istream.iostream.close = i_stream_multiplex_ichannel_close;
        channel->istream.iostream.destroy = i_stream_multiplex_ichannel_destroy;
        channel->istream.max_buffer_size = mstream->bufsize;