dovecot-2.0: IDLE: Don't assert-crash if IDLE+DONE is sent in sa...

dovecot at dovecot.org dovecot at dovecot.org
Fri Jan 21 21:46:26 EET 2011


details:   http://hg.dovecot.org/dovecot-2.0/rev/4741f1b4f9b3
changeset: 12574:4741f1b4f9b3
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jan 21 21:46:24 2011 +0200
description:
IDLE: Don't assert-crash if IDLE+DONE is sent in same TCP packet.

diffstat:

 src/imap/cmd-idle.c |  33 +++++++++++++++++++++------------
 1 files changed, 21 insertions(+), 12 deletions(-)

diffs (58 lines):

diff -r 108754651836 -r 4741f1b4f9b3 src/imap/cmd-idle.c
--- a/src/imap/cmd-idle.c	Fri Jan 21 19:16:34 2011 +0200
+++ b/src/imap/cmd-idle.c	Fri Jan 21 21:46:24 2011 +0200
@@ -55,10 +55,26 @@
 		client_command_free(&ctx->cmd);
 }
 
+static bool
+idle_client_handle_input(struct cmd_idle_context *ctx, bool free_cmd)
+{
+	const char *line;
+
+	while ((line = i_stream_next_line(ctx->client->input)) != NULL) {
+		if (ctx->client->input_skip_line)
+			ctx->client->input_skip_line = FALSE;
+		else {
+			idle_finish(ctx, strcasecmp(line, "DONE") == 0,
+				    free_cmd);
+			return TRUE;
+		}
+	}
+	return FALSE;
+}
+
 static void idle_client_input_more(struct cmd_idle_context *ctx)
 {
 	struct client *client = ctx->client;
-	char *line;
 
 	client->last_input = ioloop_time;
 	timeout_reset(client->to_idle);
@@ -82,15 +98,9 @@
 		return;
 	}
 
-	while ((line = i_stream_next_line(client->input)) != NULL) {
-		if (client->input_skip_line)
-			client->input_skip_line = FALSE;
-		else {
-			idle_finish(ctx, strcasecmp(line, "DONE") == 0, TRUE);
-			if (!client->disconnected)
-				client_continue_pending_input(client);
-			break;
-		}
+	if (idle_client_handle_input(ctx, TRUE)) {
+		if (!client->disconnected)
+			client_continue_pending_input(client);
 	}
 }
 
@@ -264,6 +274,5 @@
 	   added mailbox-notifier, we wouldn't see them otherwise. */
 	if (client->mailbox != NULL)
 		idle_sync_now(client->mailbox, ctx);
-	idle_client_input_more(ctx);
-	return FALSE;
+	return idle_client_handle_input(ctx, FALSE);
 }


More information about the dovecot-cvs mailing list