]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: o_stream_close() - Don't reset error checking on automatic flush
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 9 Jul 2018 13:23:10 +0000 (16:23 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 24 Sep 2024 06:57:46 +0000 (09:57 +0300)
Otherwise it will be difficult to find missing o_stream_flush() calls.
The missing error handling would be found only when the flushing fails,
which would result in assert-crash.

This is how the code was originally intended to behave. Broken by
5ec4fc44e8d4e2160f07b1a7f4fce1ccfec3f6c1

src/lib/ostream.c

index 19ac1846ce9212876ef38df50b3e87e7c4cd5cb8..11b358ff1d6a0bf9dff12fa3100e57a47e046ec5 100644 (file)
@@ -55,9 +55,17 @@ static void o_stream_close_full(struct ostream *stream, bool close_parents)
           complexity for many callers. Just require that at this point
           after flushing there isn't anything in the output buffer or that
           we're ignoring all errors. */
+       bool last_errors_not_checked =
+               stream->real_stream->last_errors_not_checked;
+
        if (o_stream_flush(stream) == 0)
                i_assert(stream->real_stream->error_handling_disabled);
 
+       /* We don't want this auto-flushing to remove the need for
+          proper error checking. */
+       if (last_errors_not_checked)
+               stream->real_stream->last_errors_not_checked = TRUE;
+
        if (!stream->closed && !stream->real_stream->closing) {
                /* first mark the stream as being closed so the
                   o_stream_copy_error_from_parent() won't recurse us back