]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Make sure ostream.last_failed_errno is always set when stream_errno is set.
authorTimo Sirainen <tss@iki.fi>
Mon, 27 Oct 2014 21:29:39 +0000 (23:29 +0200)
committerTimo Sirainen <tss@iki.fi>
Mon, 27 Oct 2014 21:29:39 +0000 (23:29 +0200)
src/lib/ostream.c

index 91d94fac98fee009ba17aada3f5afba352d0de5f..6bbd3764938ec547be85620b781b79da4adf028d 100644 (file)
@@ -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;
 }