From 5cbd6f3ed012b827f181f5f214584f20641b9719 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Fri, 21 Jan 2011 19:15:37 +0200 Subject: [PATCH] zlib: Make sure output stream flushes the stream automatically when not corked. Fixes hangs with IMAP COMPRESS extension. --- src/plugins/zlib/ostream-zlib.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/zlib/ostream-zlib.c b/src/plugins/zlib/ostream-zlib.c index a3f9dc35ab..bd2b27a701 100644 --- a/src/plugins/zlib/ostream-zlib.c +++ b/src/plugins/zlib/ostream-zlib.c @@ -129,7 +129,8 @@ o_stream_zlib_send_chunk(struct zlib_ostream *zstream, } zstream->crc = crc32_data_more(zstream->crc, data, size); zstream->bytes32 += size; - zstream->flushed = FALSE; + zstream->flushed = flush == Z_SYNC_FLUSH && + zs->avail_out == sizeof(zstream->outbuf); return 0; } @@ -222,8 +223,12 @@ o_stream_zlib_sendv(struct ostream_private *stream, return -1; bytes += iov[i].iov_len; } - stream->ostream.offset += bytes; + + if (!zstream->ostream.corked) { + if (o_stream_zlib_send_flush(zstream) < 0) + return -1; + } return bytes; } -- 2.47.3