Mercurial > dovecot > core-2.2
changeset 11695:54c3d17a4038 HEAD
dsync: Fixed proxying protocol to handle sending deleted mailboxes without failing.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 01 Jul 2010 21:38:14 +0100 |
parents | d701f254ca4e |
children | e0c52292b586 |
files | src/dsync/dsync-proxy-client.c src/dsync/dsync-proxy-server-cmd.c |
diffstat | 2 files changed, 24 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- 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; }
--- 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; } }