From: Timo Sirainen Date: Mon, 27 Oct 2014 21:29:39 +0000 (+0200) Subject: lib: Make sure ostream.last_failed_errno is always set when stream_errno is set. X-Git-Tag: 2.2.16.rc1~272 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5ef6906c82f34a3edd2981dd98339cdd7bfe3bbe;p=thirdparty%2Fdovecot%2Fcore.git lib: Make sure ostream.last_failed_errno is always set when stream_errno is set. --- diff --git a/src/lib/ostream.c b/src/lib/ostream.c index 91d94fac98..6bbd376493 100644 --- a/src/lib/ostream.c +++ b/src/lib/ostream.c @@ -55,8 +55,12 @@ static void o_stream_close_full(struct ostream *stream, bool close_parents) stream->closed = TRUE; } - if (stream->stream_errno == 0) + if (stream->stream_errno != 0) + i_assert(stream->last_failed_errno != 0); + else { stream->stream_errno = EPIPE; + stream->last_failed_errno = EPIPE; + } } void o_stream_destroy(struct ostream **stream) @@ -516,6 +520,7 @@ o_stream_default_seek(struct ostream_private *_stream, uoff_t offset ATTR_UNUSED) { _stream->ostream.stream_errno = ESPIPE; + _stream->ostream.last_failed_errno = ESPIPE; return -1; } @@ -525,6 +530,7 @@ o_stream_default_write_at(struct ostream_private *_stream, size_t size ATTR_UNUSED, uoff_t offset ATTR_UNUSED) { _stream->ostream.stream_errno = ESPIPE; + _stream->ostream.last_failed_errno = ESPIPE; return -1; }