changeset 12244:73c6b077bcba

imap IDLE: Don't send "Still here" notifications if there is already data in output buffer.
author Timo Sirainen <tss@iki.fi>
date Tue, 05 Oct 2010 22:53:58 +0100
parents 760e584b352b
children e92d2aaab3e4
files src/imap/cmd-idle.c
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/cmd-idle.c	Tue Oct 05 22:52:55 2010 +0100
+++ b/src/imap/cmd-idle.c	Tue Oct 05 22:53:58 2010 +0100
@@ -110,11 +110,15 @@
 		return;
 	}
 
-	/* Sending this keeps NATs/stateful firewalls alive. Sending this
-	   also catches dead connections. */
-	o_stream_cork(ctx->client->output);
-	client_send_line(ctx->client, "* OK Still here");
-	o_stream_uncork(ctx->client->output);
+	if (o_stream_get_buffer_used_size(ctx->client->output) == 0) {
+		/* Sending this keeps NATs/stateful firewalls alive.
+		   Sending this also catches dead connections. Don't send
+		   anything if there is already data waiting in output
+		   buffer. */
+		o_stream_cork(ctx->client->output);
+		client_send_line(ctx->client, "* OK Still here");
+		o_stream_uncork(ctx->client->output);
+	}
 	/* Make sure idling connections don't get disconnected. There are
 	   several clients that really want to IDLE forever and there's not
 	   much harm in letting them do so. */