From: Stephan Bosch Date: Thu, 23 Apr 2020 09:36:30 +0000 (+0200) Subject: lib: ostream-wrapper - Properly manage parent output events for blocking operation. X-Git-Tag: 2.3.11.2~160 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=77db6a8bbb5eaf870ecb3f1ea22a600dc8c84d07;p=thirdparty%2Fdovecot%2Fcore.git lib: ostream-wrapper - Properly manage parent output events for blocking operation. The problem was exposed by a panic occurring in src/lib-http/test-http-payload unit test: Panic: file ostream-wrapper.c: line 291 (wrapper_ostream_flush_wait): assertion failed: (io_loop_have_ios(ioloop) || io_loop_have_immediate_timeouts(ioloop)) --- diff --git a/src/lib/ostream-wrapper.c b/src/lib/ostream-wrapper.c index 62416430e3..2a3b78f963 100644 --- a/src/lib/ostream-wrapper.c +++ b/src/lib/ostream-wrapper.c @@ -178,20 +178,20 @@ static void wrapper_ostream_output_manage(struct wrapper_ostream *wostream, bool sending) { struct ostream_private *stream = &wostream->ostream; - bool no_data; + bool must_flush, no_data; if (wostream->output_closed) return; - no_data = (!sending && wrapper_ostream_is_empty(wostream)) || - (stream->corked && !wostream->flushing && - !stream->finished && !wrapper_ostream_is_filled(wostream)); + must_flush = (sending || stream->finished || wostream->flush_pending); + no_data = (wrapper_ostream_is_empty(wostream) || + (stream->corked && !wrapper_ostream_is_filled(wostream))); - if ((stream->ostream.closed || no_data) && !wostream->flush_pending) + if (!must_flush && (no_data || stream->ostream.closed)) wrapper_ostream_output_halt(wostream); else { wrapper_ostream_output_resume(wostream); - if (wostream->flush_pending && wostream->output != NULL) + if (wostream->output != NULL && must_flush) o_stream_set_flush_pending(wostream->output, TRUE); } }