From: Timo Sirainen Date: Tue, 2 Apr 2024 11:05:38 +0000 (+0300) Subject: lib: ostream-multiplex - Fix propagating parent stream error messages X-Git-Tag: 2.4.0~1589 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ca25d02408709e3f2561c2995ed45f52b524ded;p=thirdparty%2Fdovecot%2Fcore.git lib: ostream-multiplex - Fix propagating parent stream error messages --- diff --git a/src/lib/ostream-multiplex.c b/src/lib/ostream-multiplex.c index a8586b9e6c..bc893113b5 100644 --- a/src/lib/ostream-multiplex.c +++ b/src/lib/ostream-multiplex.c @@ -48,12 +48,21 @@ get_channel(struct multiplex_ostream *mstream, uint8_t cid) return NULL; } -static void propagate_error(struct multiplex_ostream *mstream, int stream_errno) +static void propagate_error(struct multiplex_ostream *mstream) { struct multiplex_ochannel *channel; - array_foreach_elem(&mstream->channels, channel) - if (channel != NULL) + int stream_errno = mstream->parent->stream_errno; + + i_assert(stream_errno != 0); + + const char *error = o_stream_get_error(mstream->parent); + array_foreach_elem(&mstream->channels, channel) { + if (channel != NULL) { channel->ostream.ostream.stream_errno = stream_errno; + io_stream_set_error(&channel->ostream.iostream, + "%s", error); + } + } } static struct multiplex_ochannel *get_next_channel(struct multiplex_ostream *mstream) @@ -101,7 +110,7 @@ o_stream_multiplex_sendv(struct multiplex_ostream *mstream) { channel->buf->data, amt } }; if ((ret = o_stream_sendv(mstream->parent, vec, N_ELEMENTS(vec))) < 0) { - propagate_error(mstream, mstream->parent->stream_errno); + propagate_error(mstream); break; } i_assert((size_t)ret == 1 + 4 + amt); @@ -150,7 +159,7 @@ static int o_stream_multiplex_ochannel_flush(struct ostream_private *stream) /* flush parent stream always, so there is room for more. */ if ((ret = o_stream_flush(mstream->parent)) <= 0) { if (ret == -1) - propagate_error(mstream, mstream->parent->stream_errno); + propagate_error(mstream); return ret; }