]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dsync: Fixed proxying protocol to handle sending deleted mailboxes without failing.
authorTimo Sirainen <tss@iki.fi>
Thu, 1 Jul 2010 20:38:14 +0000 (21:38 +0100)
committerTimo Sirainen <tss@iki.fi>
Thu, 1 Jul 2010 20:38:14 +0000 (21:38 +0100)
--HG--
branch : HEAD

src/dsync/dsync-proxy-client.c
src/dsync/dsync-proxy-server-cmd.c

index 34917bf29e1c59a697f7f3dcfef5986835ab1e5b..7bf902c9a8843b4fb33d69cfb2967efb1a08ca09 100644 (file)
@@ -436,10 +436,12 @@ proxy_client_worker_mailbox_iter_next(struct dsync_worker_mailbox_iter *_iter,
                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 @@ proxy_client_worker_subs_iter_next_line(struct proxy_client_dsync_worker_subs_it
                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 @@ proxy_client_worker_msg_iter_next(struct dsync_worker_msg_iter *_iter,
                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;
        }
index 501aa505f3df01e762c7bfa870f581d8501c86d0..0c521f6e8f83382e0f95177e0ad2b9be414552ae 100644 (file)
@@ -54,10 +54,10 @@ cmd_box_list(struct dsync_proxy_server *server,
                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 @@ static int
 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 @@ cmd_subs_list(struct dsync_proxy_server *server,
        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 @@ cmd_msg_list(struct dsync_proxy_server *server, const char *const *args)
                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;
        }
 }