changeset 12707:b71834419ea3

zlib: Make sure output stream flushes the stream automatically when not corked. Fixes hangs with IMAP COMPRESS extension.
author Timo Sirainen <tss@iki.fi>
date Fri, 21 Jan 2011 19:15:37 +0200
parents 5a3c87124066
children 108754651836
files src/plugins/zlib/ostream-zlib.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/zlib/ostream-zlib.c	Thu Jan 20 23:16:23 2011 +0200
+++ b/src/plugins/zlib/ostream-zlib.c	Fri Jan 21 19:15:37 2011 +0200
@@ -129,7 +129,8 @@
 	}
 	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 @@
 			return -1;
 		bytes += iov[i].iov_len;
 	}
+	stream->ostream.offset += bytes;
 
-	stream->ostream.offset += bytes;
+	if (!zstream->ostream.corked) {
+		if (o_stream_zlib_send_flush(zstream) < 0)
+			return -1;
+	}
 	return bytes;
 }