From 5fcc2aa187730d1de013d68faf01af11a1004630 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 5 Oct 2010 22:53:58 +0100 Subject: [PATCH] imap IDLE: Don't send "Still here" notifications if there is already data in output buffer. --- src/imap/cmd-idle.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/imap/cmd-idle.c b/src/imap/cmd-idle.c index bcb85550f1..8d87beb3d0 100644 --- a/src/imap/cmd-idle.c +++ b/src/imap/cmd-idle.c @@ -110,11 +110,15 @@ static void keepalive_timeout(struct cmd_idle_context *ctx) 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. */ -- 2.47.3