changeset 3763:454863612b5c HEAD

IDLE: Sending "DONE" + next command in same TCP packet caused the next command not to be executed until yet another command came (which usually didn't happen).
author Timo Sirainen <tss@iki.fi>
date Sun, 25 Dec 2005 12:51:25 +0200
parents 4d44a337ac08
children 852274ab176d
files src/imap/client.c src/imap/cmd-append.c src/imap/cmd-idle.c
diffstat 3 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/client.c	Sat Dec 24 00:38:25 2005 +0200
+++ b/src/imap/client.c	Sun Dec 25 12:51:25 2005 +0200
@@ -239,6 +239,7 @@
 void _client_reset_command(struct client *client)
 {
 	pool_t pool;
+	size_t size;
 
 	/* reset input idle time because command output might have taken a
 	   long time and we don't want to disconnect client immediately then */
@@ -258,6 +259,13 @@
 	client->cmd.client = client;
 
 	imap_parser_reset(client->parser);
+
+	/* if there's unread data in buffer, remember that there's input
+	   pending and we should get around to calling client_input() soon.
+	   This is mostly for APPEND/IDLE. */
+	(void)i_stream_get_data(client->input, &size);
+	if (size > 0)
+		client->input_pending = TRUE;
 }
 
 /* Skip incoming data until newline is found,
--- a/src/imap/cmd-append.c	Sat Dec 24 00:38:25 2005 +0200
+++ b/src/imap/cmd-append.c	Sun Dec 25 12:51:25 2005 +0200
@@ -105,8 +105,6 @@
 
 static void cmd_append_finish(struct cmd_append_context *ctx)
 {
-	size_t size;
-
 	ctx->client->input_skip_line = TRUE;
 
 	io_remove(ctx->client->io);
@@ -125,9 +123,6 @@
 
 	if (ctx->box != ctx->cmd->client->mailbox && ctx->box != NULL)
 		mailbox_close(ctx->box);
-
-	(void)i_stream_get_data(ctx->client->input, &size);
-	ctx->client->input_pending = size != 0;
 }
 
 static int cmd_append_continue_cancel(struct client_command_context *cmd)
--- a/src/imap/cmd-idle.c	Sat Dec 24 00:38:25 2005 +0200
+++ b/src/imap/cmd-idle.c	Sun Dec 25 12:51:25 2005 +0200
@@ -62,6 +62,9 @@
 
 	client->bad_counter = 0;
 	_client_reset_command(client);
+
+	if (client->input_pending)
+		_client_input(client);
 }
 
 static void idle_client_input(void *context)