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.)
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)
{
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;