]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: o_stream_uncork() - call o_stream_nflush() instead of o_stream_flush()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 27 Oct 2017 20:31:56 +0000 (23:31 +0300)
committerTimo Sirainen <tss@dovecot.fi>
Mon, 30 Oct 2017 11:04:53 +0000 (13:04 +0200)
Otherwise flush errors may be unintentionally ignored. This change requires
that all the o_stream_uncork() callers must call o_stream_nfinish()
afterwards, unless the ostream is set to ignore errors.

src/lib/ostream-file.c
src/lib/ostream.c
src/lib/ostream.h

index 8b0fe8d364a0bed5ba706cf72452f9a62a6b04e7..aeea71530fb64c56dd7f05c29abe8992f0277d3f 100644 (file)
@@ -344,6 +344,7 @@ static void o_stream_file_cork(struct ostream_private *stream, bool set)
                else if (!set) {
                        /* buffer flushing might close the stream */
                        ret = buffer_flush(fstream);
+                       stream->last_errors_not_checked = TRUE;
                        if (fstream->io == NULL &&
                            (ret == 0 || fstream->flush_pending) &&
                            !stream->ostream.closed) {
index cf4f28d0e1274b3d396015482f4453fb8a760ca3..d9004eb11b069c79610490f0fc2eca0f24204019 100644 (file)
@@ -502,7 +502,7 @@ static void o_stream_default_cork(struct ostream_private *_stream, bool set)
                if (_stream->parent != NULL)
                        o_stream_cork(_stream->parent);
        } else {
-               (void)o_stream_flush(&_stream->ostream);
+               o_stream_nflush(&_stream->ostream);
                if (_stream->parent != NULL)
                        o_stream_uncork(_stream->parent);
        }
index 32f95d229bee00a638b3721f80f8e72a1f078e74..248add86b532babed12b75cafd3b3362b6098c27 100644 (file)
@@ -121,6 +121,9 @@ size_t o_stream_get_max_buffer_size(struct ostream *stream);
 /* Delays sending as far as possible, writing only full buffers. Also sets
    TCP_CORK on if supported. */
 void o_stream_cork(struct ostream *stream);
+/* Try to flush the buffer by calling o_stream_nflush() and remove TCP_CORK.
+   Note that after this o_stream_nfinish() must be called, unless the stream
+   ignores errors. */
 void o_stream_uncork(struct ostream *stream);
 bool o_stream_is_corked(struct ostream *stream);
 /* Try to flush the output stream. Returns 1 if all sent, 0 if not,