From: Timo Sirainen Date: Mon, 9 Oct 2017 10:14:23 +0000 (+0300) Subject: lib: istream-multiplex - Forward i_stream_switch_ioloop() to parent X-Git-Tag: 2.2.34~305 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5010a20396194856685378dc4784f927820e0eed;p=thirdparty%2Fdovecot%2Fcore.git lib: istream-multiplex - Forward i_stream_switch_ioloop() to parent 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.) --- diff --git a/src/lib/istream-multiplex.c b/src/lib/istream-multiplex.c index a52de43312..678d856101 100644 --- a/src/lib/istream-multiplex.c +++ b/src/lib/istream-multiplex.c @@ -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;