Mercurial > dovecot > core-2.2
changeset 11804:5e285530914c
dsync: Don't give errors when doing a remote sync and there are no changes.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 12 Jul 2010 16:27:51 +0100 |
parents | fa883e27a6de |
children | 0a2dc81ed513 |
files | src/dsync/dsync-brain.c src/dsync/dsync-worker.c |
diffstat | 2 files changed, 24 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dsync/dsync-brain.c Mon Jul 12 15:32:14 2010 +0100 +++ b/src/dsync/dsync-brain.c Mon Jul 12 16:27:51 2010 +0100 @@ -710,18 +710,26 @@ } } -static void dsync_brain_sync_msgs(struct dsync_brain *brain) +static bool dsync_brain_sync_msgs(struct dsync_brain *brain) { ARRAY_TYPE(dsync_brain_mailbox) mailboxes; pool_t pool; + bool ret; pool = pool_alloconly_create("dsync changed mailboxes", 10240); p_array_init(&mailboxes, pool, 128); dsync_brain_get_changed_mailboxes(brain, &mailboxes, (brain->flags & DSYNC_BRAIN_FLAG_FULL_SYNC) != 0); - brain->mailbox_sync = dsync_brain_msg_sync_init(brain, &mailboxes); - dsync_brain_msg_sync_more(brain->mailbox_sync); + if (array_count(&mailboxes) > 0) { + brain->mailbox_sync = + dsync_brain_msg_sync_init(brain, &mailboxes); + dsync_brain_msg_sync_more(brain->mailbox_sync); + ret = TRUE; + } else { + ret = FALSE; + } pool_unref(&pool); + return ret; } static void @@ -748,6 +756,11 @@ dsync_worker_has_failed(brain->src_worker) || dsync_worker_has_failed(brain->dest_worker); + if (brain->mailbox_sync == NULL) { + /* no mailboxes changed */ + return; + } + array_foreach(&brain->mailbox_sync->mailboxes, mailbox) { /* don't update mailboxes if any changes had failed. for example if some messages couldn't be saved, we don't @@ -813,6 +826,9 @@ dsync_worker_subs_input(brain->dest_subs_list); break; case DSYNC_STATE_SYNC_MAILBOXES: + dsync_worker_set_input_callback(brain->src_worker, NULL, NULL); + dsync_worker_set_input_callback(brain->dest_worker, NULL, NULL); + dsync_brain_sync_mailboxes(brain); dsync_brain_sync_dirs(brain); brain->state++; @@ -822,8 +838,10 @@ brain->state++; /* fall through */ case DSYNC_STATE_SYNC_MSGS: - dsync_brain_sync_msgs(brain); - break; + if (dsync_brain_sync_msgs(brain)) + break; + brain->state++; + /* no mailboxes changed */ case DSYNC_STATE_SYNC_MSGS_FLUSH: /* wait until all saves are done, so we don't try to close the mailbox too early */
--- a/src/dsync/dsync-worker.c Mon Jul 12 15:32:14 2010 +0100 +++ b/src/dsync/dsync-worker.c Mon Jul 12 16:27:51 2010 +0100 @@ -108,6 +108,7 @@ const mailbox_guid_t mailboxes[], unsigned int mailbox_count) { + i_assert(mailbox_count > 0); return worker->v.msg_iter_init(worker, mailboxes, mailbox_count); }