From: Timo Sirainen Date: Fri, 27 Oct 2017 21:59:57 +0000 (+0300) Subject: lib: Remove o_stream_nflush() X-Git-Tag: 2.3.0.rc1~710 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b688884f23be2333bea1a8bd4ee849336aebedaa;p=thirdparty%2Fdovecot%2Fcore.git lib: Remove o_stream_nflush() None of its previous callers were calling it correctly, so it's better to remove it entirely to avoid more of such wrong calls. --- diff --git a/src/lib/ostream.c b/src/lib/ostream.c index d9004eb11b..4ea970c58c 100644 --- a/src/lib/ostream.c +++ b/src/lib/ostream.c @@ -315,17 +315,9 @@ void o_stream_nsend_str(struct ostream *stream, const char *str) o_stream_nsend(stream, str, strlen(str)); } -void o_stream_nflush(struct ostream *stream) -{ - if (unlikely(stream->closed || stream->stream_errno != 0)) - return; - (void)o_stream_flush(stream); - stream->real_stream->last_errors_not_checked = TRUE; -} - int o_stream_nfinish(struct ostream *stream) { - o_stream_nflush(stream); + (void)o_stream_flush(stream); o_stream_ignore_last_errors(stream); if (stream->stream_errno == 0 && stream->real_stream->noverflow) { io_stream_set_error(&stream->real_stream->iostream, @@ -502,7 +494,9 @@ static void o_stream_default_cork(struct ostream_private *_stream, bool set) if (_stream->parent != NULL) o_stream_cork(_stream->parent); } else { - o_stream_nflush(&_stream->ostream); + (void)o_stream_flush(&_stream->ostream); + _stream->last_errors_not_checked = TRUE; + if (_stream->parent != NULL) o_stream_uncork(_stream->parent); } diff --git a/src/lib/ostream.h b/src/lib/ostream.h index 248add86b5..e0f4c50e9f 100644 --- a/src/lib/ostream.h +++ b/src/lib/ostream.h @@ -121,7 +121,7 @@ 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. +/* Try to flush the buffer by calling o_stream_flush() 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); @@ -154,7 +154,6 @@ void o_stream_nsend(struct ostream *stream, const void *data, size_t size); void o_stream_nsendv(struct ostream *stream, const struct const_iovec *iov, unsigned int iov_count); void o_stream_nsend_str(struct ostream *stream, const char *str); -void o_stream_nflush(struct ostream *stream); /* Marks the stream's error handling as completed. Flushes the stream and returns -1 if stream->stream_errno is non-zero. Returns failure if any of the o_stream_nsend*() didn't write all data. */