dovecot-2.0: imap: Make sure we don't crash when client disconne...

dovecot at dovecot.org dovecot at dovecot.org
Wed Sep 1 19:48:19 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/4d9768fd1a55
changeset: 12060:4d9768fd1a55
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Sep 01 17:48:04 2010 +0100
description:
imap: Make sure we don't crash when client disconnects during IDLE with lots of changes.

diffstat:

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

diffs (50 lines):

diff -r 75611e9088b6 -r 4d9768fd1a55 src/imap/cmd-idle.c
--- a/src/imap/cmd-idle.c	Wed Sep 01 17:37:31 2010 +0100
+++ b/src/imap/cmd-idle.c	Wed Sep 01 17:48:04 2010 +0100
@@ -55,7 +55,7 @@
 		client_command_free(&ctx->cmd);
 }
 
-static void idle_client_input(struct cmd_idle_context *ctx)
+static void idle_client_input_more(struct cmd_idle_context *ctx)
 {
 	struct client *client = ctx->client;
 	char *line;
@@ -66,7 +66,7 @@
 	switch (i_stream_read(client->input)) {
 	case -1:
 		/* disconnected */
-		client_destroy(client, "Disconnected in IDLE");
+		client_disconnect(client, "Disconnected in IDLE");
 		return;
 	case -2:
 		client->input_skip_line = TRUE;
@@ -90,10 +90,17 @@
 			break;
 		}
 	}
+	if (!client->disconnected)
+		client_continue_pending_input(client);
+}
+
+static void idle_client_input(struct cmd_idle_context *ctx)
+{
+	struct client *client = ctx->client;
+
+	idle_client_input_more(ctx);
 	if (client->disconnected)
 		client_destroy(client, NULL);
-	else
-		client_continue_pending_input(client);
 }
 
 static void keepalive_timeout(struct cmd_idle_context *ctx)
@@ -217,7 +224,7 @@
 		/* input is pending */
 		client->io = io_add(i_stream_get_fd(client->input),
 				    IO_READ, idle_client_input, ctx);
-		idle_client_input(ctx);
+		idle_client_input_more(ctx);
 	}
 	return FALSE;
 }


More information about the dovecot-cvs mailing list