dovecot-2.0: dsync: Fixed proxying protocol to handle sending de...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jul 1 23:38:18 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/54c3d17a4038
changeset: 11695:54c3d17a4038
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jul 01 21:38:14 2010 +0100
description:
dsync: Fixed proxying protocol to handle sending deleted mailboxes without failing.

diffstat:

 src/dsync/dsync-proxy-client.c     |  18 ++++++++++++------
 src/dsync/dsync-proxy-server-cmd.c |  25 ++++++++++++-------------
 2 files changed, 24 insertions(+), 19 deletions(-)

diffs (115 lines):

diff -r d701f254ca4e -r 54c3d17a4038 src/dsync/dsync-proxy-client.c
--- a/src/dsync/dsync-proxy-client.c	Thu Jul 01 20:59:33 2010 +0100
+++ b/src/dsync/dsync-proxy-client.c	Thu Jul 01 21:38:14 2010 +0100
@@ -436,10 +436,12 @@
 		return ret;
 	}
 
-	if (*line == '\t') {
+	if ((line[0] == '+' || line[0] == '-') && line[1] == '\0') {
 		/* end of mailboxes */
-		if (line[1] != '0')
+		if (line[0] == '-') {
+			i_error("Worker server's mailbox iteration failed");
 			_iter->failed = TRUE;
+		}
 		return -1;
 	}
 
@@ -497,10 +499,12 @@
 		return ret;
 	}
 
-	if (*line == '\t') {
+	if ((line[0] == '+' || line[0] == '-') && line[1] == '\0') {
 		/* end of subscribed subscriptions */
-		if (line[1] != '0')
+		if (line[0] == '-') {
+			i_error("Worker server's subscription iteration failed");
 			iter->iter.failed = TRUE;
+		}
 		return -1;
 	}
 
@@ -647,10 +651,12 @@
 		return ret;
 	}
 
-	if (*line == '\t') {
+	if ((line[0] == '+' || line[0] == '-') && line[1] == '\0') {
 		/* end of messages */
-		if (line[1] != '0')
+		if (line[0] == '-') {
+			i_error("Worker server's message iteration failed");
 			_iter->failed = TRUE;
+		}
 		iter->done = TRUE;
 		return -1;
 	}
diff -r d701f254ca4e -r 54c3d17a4038 src/dsync/dsync-proxy-server-cmd.c
--- a/src/dsync/dsync-proxy-server-cmd.c	Thu Jul 01 20:59:33 2010 +0100
+++ b/src/dsync/dsync-proxy-server-cmd.c	Thu Jul 01 21:38:14 2010 +0100
@@ -54,10 +54,10 @@
 		return 0;
 	}
 	if (dsync_worker_mailbox_iter_deinit(&server->mailbox_iter) < 0) {
-		o_stream_send(server->output, "\t-1\n", 4);
+		o_stream_send(server->output, "-\n", 2);
 		return -1;
 	} else {
-		o_stream_send(server->output, "\t0\n", 3);
+		o_stream_send(server->output, "+\n", 2);
 		return 1;
 	}
 }
@@ -120,8 +120,6 @@
 cmd_subs_list(struct dsync_proxy_server *server,
 	      const char *const *args ATTR_UNUSED)
 {
-	int ret = 1;
-
 	if (server->subs_iter == NULL) {
 		server->subs_iter =
 			dsync_worker_subs_iter_init(server->worker);
@@ -130,20 +128,21 @@
 	if (!server->subs_sending_unsubscriptions) {
 		if (!cmd_subs_list_subscriptions(server))
 			return 0;
-		o_stream_send(server->output, "\t0\n", 3);
+		/* a bit hacky way to handle this. this assumes that caller
+		   goes through all subscriptions first, and next starts
+		   going through unsubscriptions */
+		o_stream_send(server->output, "+\n", 2);
 		server->subs_sending_unsubscriptions = TRUE;
 	}
-	if (ret > 0) {
-		if (!cmd_subs_list_unsubscriptions(server))
-			return 0;
-	}
+	if (!cmd_subs_list_unsubscriptions(server))
+		return 0;
 
 	server->subs_sending_unsubscriptions = FALSE;
 	if (dsync_worker_subs_iter_deinit(&server->subs_iter) < 0) {
-		o_stream_send(server->output, "\t-1\n", 4);
+		o_stream_send(server->output, "-\n", 2);
 		return -1;
 	} else {
-		o_stream_send(server->output, "\t0\n", 3);
+		o_stream_send(server->output, "+\n", 2);
 		return 1;
 	}
 }
@@ -217,10 +216,10 @@
 		return 0;
 	}
 	if (dsync_worker_msg_iter_deinit(&server->msg_iter) < 0) {
-		o_stream_send(server->output, "\t-1\n", 4);
+		o_stream_send(server->output, "-\n", 2);
 		return -1;
 	} else {
-		o_stream_send(server->output, "\t0\n", 3);
+		o_stream_send(server->output, "+\n", 2);
 		return 1;
 	}
 }


More information about the dovecot-cvs mailing list