Mercurial > dovecot > core-2.2
diff src/doveadm/dsync/dsync-brain.c @ 18351:b4dbe64c0032
dsync: Added an extra "finish" state to allow slave-dsync to report error to master-dsync.
I'm not sure if that's actually necessary, but just trying to follow the
different possibilities on how dsync run can finish made me unsure about it.
This should make it at least clear that if a slave-dsync has a failure flag
set at deinit master-dsync will know about it before it returns success.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 13 Mar 2015 20:08:34 +0200 |
parents | 06c4c42549a7 |
children | b900b50085fc |
line wrap: on
line diff
--- a/src/doveadm/dsync/dsync-brain.c Fri Mar 13 20:05:03 2015 +0200 +++ b/src/doveadm/dsync/dsync-brain.c Fri Mar 13 20:08:34 2015 +0200 @@ -30,6 +30,7 @@ "master_send_mailbox", "slave_recv_mailbox", "sync_mails", + "finish", "done" }; @@ -554,6 +555,26 @@ return changed; } +static bool dsync_brain_finish(struct dsync_brain *brain) +{ + const char *error; + + if (!brain->master_brain) { + dsync_ibc_send_finish(brain->ibc, + brain->failed ? "dsync failed" : NULL); + brain->state = DSYNC_STATE_DONE; + return TRUE; + } + if (dsync_ibc_recv_finish(brain->ibc, &error) == DSYNC_IBC_RECV_RET_TRYAGAIN) + return FALSE; + if (error != NULL) { + i_error("Remote dsync failed: %s", error); + brain->failed = TRUE; + } + brain->state = DSYNC_STATE_DONE; + return TRUE; +} + static bool dsync_brain_run_real(struct dsync_brain *brain, bool *changed_r) { enum dsync_state orig_state = brain->state; @@ -602,6 +623,9 @@ case DSYNC_STATE_SYNC_MAILS: changed = dsync_brain_sync_mails(brain); break; + case DSYNC_STATE_FINISH: + changed = dsync_brain_finish(brain); + break; case DSYNC_STATE_DONE: changed = TRUE; ret = FALSE;