From: Timo Sirainen Date: Thu, 29 Apr 2010 17:14:43 +0000 (+0300) Subject: zlib: Fixed zlib/bzlib ostream flushing to report correctly when it's finished. X-Git-Tag: 2.0.beta5~48 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=941a072da8b944e3ed0b6ebc0c43f1192436efba;p=thirdparty%2Fdovecot%2Fcore.git zlib: Fixed zlib/bzlib ostream flushing to report correctly when it's finished. This caused imap-zlib plugin to eat all CPU when stream compression was used. Patch by Apple. --HG-- branch : HEAD --- diff --git a/src/plugins/zlib/ostream-bzlib.c b/src/plugins/zlib/ostream-bzlib.c index ccbcb3ebc5..ad0d41dc7b 100644 --- a/src/plugins/zlib/ostream-bzlib.c +++ b/src/plugins/zlib/ostream-bzlib.c @@ -122,15 +122,15 @@ static int o_stream_bzlib_send_flush(struct bzlib_ostream *zstream) static int o_stream_bzlib_flush(struct ostream_private *stream) { struct bzlib_ostream *zstream = (struct bzlib_ostream *)stream; + int ret; if (o_stream_bzlib_send_flush(zstream) < 0) return -1; - if (o_stream_flush(zstream->output) < 0) { + ret = o_stream_flush(zstream->output); + if (ret < 0) zstream_copy_error(zstream); - return -1; - } - return 0; + return ret; } static ssize_t diff --git a/src/plugins/zlib/ostream-zlib.c b/src/plugins/zlib/ostream-zlib.c index 6e5d83b472..750e852d16 100644 --- a/src/plugins/zlib/ostream-zlib.c +++ b/src/plugins/zlib/ostream-zlib.c @@ -184,15 +184,15 @@ static int o_stream_zlib_send_flush(struct zlib_ostream *zstream) static int o_stream_zlib_flush(struct ostream_private *stream) { struct zlib_ostream *zstream = (struct zlib_ostream *)stream; + int ret; if (o_stream_zlib_send_flush(zstream) < 0) return -1; - if (o_stream_flush(zstream->output) < 0) { + ret = o_stream_flush(zstream->output); + if (ret < 0) zstream_copy_error(zstream); - return -1; - } - return 0; + return ret; } static ssize_t