changeset 22584:51b74dbe1ce9

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.)
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Mon, 09 Oct 2017 13:14:23 +0300
parents 21c8f6efa1e3
children e1ad624fc2ad
files src/lib/istream-multiplex.c
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/istream-multiplex.c	Mon Oct 09 01:22:47 2017 +0300
+++ b/src/lib/istream-multiplex.c	Mon Oct 09 13:14:23 2017 +0300
@@ -182,6 +182,14 @@
 }
 
 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)
 {
 	struct multiplex_ichannel *const *channelp;
@@ -229,6 +237,7 @@
 	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;