changeset 2800:3f7d4af90ec1 HEAD

IDLE used 100% CPU.
author Timo Sirainen <tss@iki.fi>
date Thu, 21 Oct 2004 05:36:29 +0300
parents be9a3a706b7a
children 7cf652f2a33a
files src/imap/client.c src/imap/client.h src/imap/cmd-idle.c
diffstat 3 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/client.c	Thu Oct 21 05:27:12 2004 +0300
+++ b/src/imap/client.c	Thu Oct 21 05:36:29 2004 +0300
@@ -392,9 +392,15 @@
 
 	/* continue processing command */
 	o_stream_cork(client->output);
+	client->output_pending = TRUE;
 	finished = client->cmd_func(client) || client->cmd_param_error;
 	o_stream_uncork(client->output);
 
+	/* a bit kludgy. normally we would want to get back here, but IDLE
+	   is a special case which has command pending but without necessarily
+	   anything to write. */
+	ret = finished || !client->output_pending;
+
 	if (finished) {
 		/* command execution was finished */
 		client->bad_counter = 0;
@@ -403,7 +409,7 @@
 		if (client->input_pending)
 			_client_input(client);
 	}
-	return finished;
+	return ret;
 }
 
 static void idle_timeout(void *context __attr_unused__)
--- a/src/imap/client.h	Thu Oct 21 05:27:12 2004 +0300
+++ b/src/imap/client.h	Thu Oct 21 05:36:29 2004 +0300
@@ -39,6 +39,7 @@
 
 	unsigned int command_pending:1;
 	unsigned int input_pending:1;
+	unsigned int output_pending:1;
 	unsigned int cmd_uid:1; /* used UID command */
 	unsigned int cmd_param_error:1;
 	unsigned int rawlog:1;
--- a/src/imap/cmd-idle.c	Thu Oct 21 05:27:12 2004 +0300
+++ b/src/imap/cmd-idle.c	Thu Oct 21 05:36:29 2004 +0300
@@ -162,6 +162,7 @@
                 idle_callback(client->mailbox, client);
 	}
 
+        client->output_pending = FALSE;
 	return FALSE;
 }