Mercurial > dovecot > original-hg > dovecot-1.2
changeset 4832:9ea62a9720ec HEAD
When mailbox changes are noticed and they're sent to client, cork before
doing it so each command isn't sent in a separate packet. (this was done in
branch_1_0 already, but forgot to commit to HEAD)
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 18 Nov 2006 23:37:21 +0200 |
parents | 7e50162a378c |
children | cf97623a0aeb |
files | src/imap/cmd-idle.c |
diffstat | 1 files changed, 20 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/cmd-idle.c Sat Nov 18 23:34:22 2006 +0200 +++ b/src/imap/cmd-idle.c Sat Nov 18 23:37:21 2006 +0200 @@ -22,6 +22,7 @@ struct timeout *idle_to, *keepalive_to; uint32_t dummy_seq; + unsigned int manual_cork:1; unsigned int idle_timeout:1; unsigned int sync_pending:1; }; @@ -161,8 +162,10 @@ if (ctx->sync_ctx != NULL) ctx->sync_pending = TRUE; - else - idle_sync_now(box, ctx); + else { + ctx->manual_cork = TRUE; + idle_sync_now(box, ctx); + } } static bool cmd_idle_continue(struct client_command_context *cmd) @@ -170,9 +173,19 @@ struct client *client = cmd->client; struct cmd_idle_context *ctx = cmd->context; + if (ctx->manual_cork) { + /* we're coming from idle_callback instead of a normal + I/O handler, so we'll have to do corking manually */ + o_stream_cork(client->output); + } + if (ctx->sync_ctx != NULL) { if (imap_sync_more(ctx->sync_ctx) == 0) { /* unfinished */ + if (ctx->manual_cork) { + ctx->manual_cork = FALSE; + o_stream_uncork(client->output); + } return FALSE; } @@ -197,6 +210,11 @@ } client->output_pending = FALSE; + if (ctx->manual_cork) { + ctx->manual_cork = FALSE; + o_stream_uncork(client->output); + } + if (client->output->closed) { idle_finish(ctx, FALSE); return TRUE;