dovecot-1.1: Try to send tagged replies in the same order as the...

dovecot at dovecot.org dovecot at dovecot.org
Thu Mar 20 16:55:49 EET 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/4407b7265afd
changeset: 7434:4407b7265afd
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Mar 20 16:55:44 2008 +0200
description:
Try to send tagged replies in the same order as the commands were received
(fixes Apple Mail bug).

diffstat:

1 file changed, 15 insertions(+), 7 deletions(-)
src/imap/imap-sync.c |   22 +++++++++++++++-------

diffs (48 lines):

diff -r 0ee365c21c16 -r 4407b7265afd src/imap/imap-sync.c
--- a/src/imap/imap-sync.c	Thu Mar 20 16:54:19 2008 +0200
+++ b/src/imap/imap-sync.c	Thu Mar 20 16:55:44 2008 +0200
@@ -210,7 +210,7 @@ static bool cmd_finish_sync(struct clien
 
 static bool cmd_sync_continue(struct client_command_context *sync_cmd)
 {
-	struct client_command_context *cmd, *next;
+	struct client_command_context *cmd, *prev;
 	struct client *client = sync_cmd->client;
 	struct imap_sync_context *ctx = sync_cmd->context;
 	int ret;
@@ -229,9 +229,13 @@ static bool cmd_sync_continue(struct cli
 	}
 	sync_cmd->context = NULL;
 
-	/* finish all commands that waited for this sync */
-	for (cmd = client->command_queue; cmd != NULL; cmd = next) {
-		next = cmd->next;
+	/* Finish all commands that waited for this sync. Go through the queue
+	   backwards, so that tagged replies are sent in the same order as
+	   they were received. This fixes problems with clients that rely on
+	   this (Apple Mail 3.2) */
+	for (cmd = client->command_queue; cmd->next != NULL; cmd = cmd->next) ;
+	for (; cmd != NULL; cmd = prev) {
+		prev = cmd->prev;
 
 		if (cmd->state == CLIENT_COMMAND_STATE_WAIT_SYNC &&
 		    cmd != sync_cmd &&
@@ -365,11 +369,15 @@ bool cmd_sync_callback(struct client_com
 
 static bool cmd_sync_drop_fast(struct client *client)
 {
-	struct client_command_context *cmd, *next;
+	struct client_command_context *cmd, *prev;
 	bool ret = FALSE;
 
-	for (cmd = client->command_queue; cmd != NULL; cmd = next) {
-		next = cmd->next;
+	if (client->command_queue == NULL)
+		return FALSE;
+
+	for (cmd = client->command_queue; cmd->next != NULL; cmd = cmd->next) ;
+	for (; cmd != NULL; cmd = prev) {
+		prev = cmd->next;
 
 		if (cmd->state == CLIENT_COMMAND_STATE_WAIT_SYNC &&
 		    (cmd->sync->flags & MAILBOX_SYNC_FLAG_FAST) != 0) {


More information about the dovecot-cvs mailing list