changeset 19414:20e51832875e

imap: IDLE may have called client_continue_pending_input() unnecessarily.
author Timo Sirainen <tss@iki.fi>
date Tue, 24 Nov 2015 13:40:12 +0200
parents 8d9b48c59490
children ecfd706b0e21
files src/imap/cmd-idle.c
diffstat 1 files changed, 12 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/cmd-idle.c	Tue Nov 24 12:56:35 2015 +0200
+++ b/src/imap/cmd-idle.c	Tue Nov 24 13:40:12 2015 +0200
@@ -72,7 +72,7 @@
 	return FALSE;
 }
 
-static void idle_client_input_more(struct cmd_idle_context *ctx)
+static bool idle_client_input_more(struct cmd_idle_context *ctx)
 {
 	struct client *client = ctx->client;
 
@@ -83,34 +83,33 @@
 	case -1:
 		/* disconnected */
 		client_disconnect(client, NULL);
-		return;
+		return TRUE;
 	case -2:
 		client->input_skip_line = TRUE;
 		idle_finish(ctx, FALSE, TRUE);
-		client_continue_pending_input(client);
-		return;
+		return TRUE;
 	}
 
 	if (ctx->sync_ctx != NULL) {
 		/* we're still sending output to client. wait until it's all
 		   sent so we don't lose any changes. */
 		io_remove(&client->io);
-		return;
+		return FALSE;
 	}
 
-	if (idle_client_handle_input(ctx, TRUE)) {
-		if (!client->disconnected)
-			client_continue_pending_input(client);
-	}
+	return idle_client_handle_input(ctx, TRUE);
 }
 
 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);
+	if (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)
@@ -271,7 +270,7 @@
 		/* input is pending */
 		client->io = io_add_istream(client->input,
 					    idle_client_input, ctx);
-		idle_client_input_more(ctx);
+		(void)idle_client_input_more(ctx);
 	}
 	return FALSE;
 }