[dovecot-cvs] dovecot/src/imap cmd-idle.c,1.32,1.33

tss at dovecot.org tss at dovecot.org
Sat Nov 18 21:37:23 UTC 2006


Update of /var/lib/cvs/dovecot/src/imap
In directory talvi:/tmp/cvs-serv5721

Modified Files:
	cmd-idle.c 
Log Message:
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)



Index: cmd-idle.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/cmd-idle.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- cmd-idle.c	18 Nov 2006 21:29:58 -0000	1.32
+++ cmd-idle.c	18 Nov 2006 21:37:21 -0000	1.33
@@ -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;



More information about the dovecot-cvs mailing list