]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: o_stream_uncork() could also cause write errors. Make sure last_failed_errno...
authorTimo Sirainen <tss@iki.fi>
Mon, 27 Oct 2014 21:26:10 +0000 (23:26 +0200)
committerTimo Sirainen <tss@iki.fi>
Mon, 27 Oct 2014 21:26:10 +0000 (23:26 +0200)
This caused some write errors not to be detected, such as in code like:

o_stream_cork()
o_stream_nsend(..)
o_stream_uncork()
if (o_stream_nfinish() < 0) {
  // error not detected because last_failed_errno was 0
}

src/lib/ostream.c

index 3d69d88216c15711d561178e26e97502eefd8ec1..91d94fac98fee009ba17aada3f5afba352d0de5f 100644 (file)
@@ -134,7 +134,10 @@ void o_stream_uncork(struct ostream *stream)
        if (unlikely(stream->closed))
                return;
 
+       stream->stream_errno = 0;
        _stream->cork(_stream, FALSE);
+       if (stream->stream_errno != 0)
+               errno = stream->last_failed_errno = stream->stream_errno;
 }
 
 bool o_stream_is_corked(struct ostream *stream)