dovecot: Fixes to handling command ambiguity. Don't allow any co...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jun 27 22:37:22 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/71176467310e
changeset: 5812:71176467310e
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jun 27 21:22:22 2007 +0300
description:
Fixes to handling command ambiguity. Don't allow any commands that handle
messages be run while mailbox is being synced.

diffstat:

3 files changed, 20 insertions(+), 6 deletions(-)
src/imap/client.c    |   23 +++++++++++++++++------
src/imap/client.h    |    1 +
src/imap/imap-sync.c |    2 ++

diffs (84 lines):

diff -r e0b451e0c190 -r 71176467310e src/imap/client.c
--- a/src/imap/client.c	Wed Jun 27 20:21:00 2007 +0300
+++ b/src/imap/client.c	Wed Jun 27 21:22:22 2007 +0300
@@ -312,8 +312,13 @@ static bool client_command_check_ambigui
 		return FALSE;
 	}
 
-	if (client_command_find_with_flags(cmd, flags) == NULL)
-		return FALSE;
+	if (client_command_find_with_flags(cmd, flags) == NULL) {
+		if (cmd->client->syncing) {
+			/* don't do anything until syncing is finished */
+			return TRUE;
+		}
+		return FALSE;
+	}
 
 	if (broken_client) {
 		client_send_line(cmd->client,
@@ -420,6 +425,7 @@ void client_continue_pending_input(struc
 		   commands to finish. */
 		if (client_command_check_ambiguity(client->input_lock))
 			return;
+		client->input_lock->waiting_unambiguity = FALSE;
 	}
 
 	client_add_missing_io(client);
@@ -522,8 +528,11 @@ static bool client_handle_next_command(s
 {
 	size_t size;
 
-	if (client->input_lock != NULL)
+	if (client->input_lock != NULL) {
+		if (client->input_lock->waiting_unambiguity)
+			return FALSE;
 		return client_command_input(client->input_lock);
+	}
 
 	if (client->input_skip_line) {
 		/* first eat the previous command line */
@@ -632,9 +641,11 @@ int _client_output(struct client *client
 		cmd = client->command_queue;
 		for (; cmd != NULL; cmd = next) {
 			next = cmd->next;
-			client_output_cmd(cmd);
-			if (client->output_lock != NULL)
-				break;
+			if (!cmd->waiting_unambiguity) {
+				client_output_cmd(cmd);
+				if (client->output_lock != NULL)
+					break;
+			}
 		}
 	}
 	o_stream_uncork(client->output);
diff -r e0b451e0c190 -r 71176467310e src/imap/client.h
--- a/src/imap/client.h	Wed Jun 27 20:21:00 2007 +0300
+++ b/src/imap/client.h	Wed Jun 27 21:22:22 2007 +0300
@@ -67,6 +67,7 @@ struct client {
 	unsigned int destroyed:1;
 	unsigned int handling_input:1;
 	unsigned int idling:1;
+	unsigned int syncing:1;
 	unsigned int input_skip_line:1; /* skip all the data until we've
 					   found a new line */
 };
diff -r e0b451e0c190 -r 71176467310e src/imap/imap-sync.c
--- a/src/imap/imap-sync.c	Wed Jun 27 20:21:00 2007 +0300
+++ b/src/imap/imap-sync.c	Wed Jun 27 21:22:22 2007 +0300
@@ -218,6 +218,7 @@ static bool cmd_sync_continue(struct cli
 	if (ret < 0)
 		ctx->sync_ctx->failed = TRUE;
 
+	cmd->client->syncing = FALSE;
 	if (imap_sync_deinit(ctx->sync_ctx) < 0) {
 		client_send_untagged_storage_error(cmd->client,
 			mailbox_get_storage(cmd->client->mailbox));
@@ -263,5 +264,6 @@ bool cmd_sync(struct client_command_cont
 	if (client->input_lock == cmd)
 		client->input_lock = NULL;
 	client->output_lock = NULL;
+	client->syncing = TRUE;
 	return cmd_sync_continue(cmd);
 }


More information about the dovecot-cvs mailing list