Here is a patch to fix the problem where an imap process runs away when
imap-zlib is in use. The backtrace showed:
io_loop_handler_run ->
stream_send_io ->
client_output ->
o_stream_flush ->
o_stream_zlib_flush ->
o_stream_zlib_send_flush
When o_stream_zlib_flush returns 0, stream_send_io reinstates the IO_WRITE
event, causing the infinite loop.
diff -ur dovecot-2.0.beta4/src/plugins/zlib/ostream-bzlib.c
dovecot-2.0.beta4+fix/src/plugins/zlib/ostream-bzlib.c
--- dovecot-2.0.beta4/src/plugins/zlib/ostream-bzlib.c 2010-02-12
20:22:07.000000000 -0600
+++ dovecot-2.0.beta4+fix/src/plugins/zlib/ostream-bzlib.c 2010-04-20
19:15:29.000000000 -0500
@@ -122,15 +122,15 @@
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 -ur dovecot-2.0.beta4/src/plugins/zlib/ostream-zlib.c
dovecot-2.0.beta4+fix/src/plugins/zlib/ostream-zlib.c
--- dovecot-2.0.beta4/src/plugins/zlib/ostream-zlib.c 2010-02-18
22:01:56.000000000 -0600
+++ dovecot-2.0.beta4+fix/src/plugins/zlib/ostream-zlib.c 2010-04-20
19:15:29.000000000 -0500
@@ -184,15 +184,15 @@
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