From a9b269843f1b3fcff865e3ae2cf3a75ff48bc5e7 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 1 Jul 2010 21:38:14 +0100 Subject: [PATCH] dsync: Fixed proxying protocol to handle sending deleted mailboxes without failing. --HG-- branch : HEAD --- src/dsync/dsync-proxy-client.c | 18 ++++++++++++------ src/dsync/dsync-proxy-server-cmd.c | 25 ++++++++++++------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/dsync/dsync-proxy-client.c b/src/dsync/dsync-proxy-client.c index 34917bf29e..7bf902c9a8 100644 --- a/src/dsync/dsync-proxy-client.c +++ b/src/dsync/dsync-proxy-client.c @@ -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; } diff --git a/src/dsync/dsync-proxy-server-cmd.c b/src/dsync/dsync-proxy-server-cmd.c index 501aa505f3..0c521f6e8f 100644 --- a/src/dsync/dsync-proxy-server-cmd.c +++ b/src/dsync/dsync-proxy-server-cmd.c @@ -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; } } -- 2.47.3