From: Timo Sirainen Date: Mon, 27 Oct 2014 21:26:10 +0000 (+0200) Subject: lib: o_stream_uncork() could also cause write errors. Make sure last_failed_errno... X-Git-Tag: 2.2.16.rc1~273 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d08e08aebe5aa5d6147767d393a0a15aef08ce7e;p=thirdparty%2Fdovecot%2Fcore.git lib: o_stream_uncork() could also cause write errors. Make sure last_failed_errno is updated. 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 } --- diff --git a/src/lib/ostream.c b/src/lib/ostream.c index 3d69d88216..91d94fac98 100644 --- a/src/lib/ostream.c +++ b/src/lib/ostream.c @@ -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)