dsync-brain.c revision 2d66fbf7a14d354cd7ffa3e504fc660a99f22f75
/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "hash.h"
#include "hostpid.h"
#include "mail-namespace.h"
#include "dsync-mailbox-tree.h"
#include "dsync-ibc.h"
#include "dsync-brain-private.h"
"recv_handshake",
"send_last_common",
"recv_last_common",
"send_mailbox_tree",
"send_mailbox_tree_deletes",
"recv_mailbox_tree",
"recv_mailbox_tree_deletes",
"master_send_mailbox",
"slave_recv_mailbox",
"sync_mails",
"done"
};
static void dsync_brain_run_io(void *context)
{
bool changed, try_pending;
return;
}
try_pending = TRUE;
do {
break;
}
if (changed)
try_pending = TRUE;
else if (try_pending) {
try_pending = FALSE;
}
} while (changed);
}
static struct dsync_brain *
{
struct dsync_brain *brain;
return brain;
}
static void
{
(flags & DSYNC_BRAIN_FLAG_SEND_MAIL_REQUESTS) != 0;
}
struct dsync_brain *
const guid_128_t sync_box_guid,
const char *state)
{
struct dsync_ibc_settings ibc_set;
struct dsync_brain *brain;
const char *error;
if (sync_type == DSYNC_BRAIN_SYNC_TYPE_STATE &&
i_error("Saved sync state is invalid, "
"falling back to full sync: %s", error);
}
sizeof(ibc_set.sync_box_guid));
/* reverse the backup direction for the slave */
if ((flags & DSYNC_BRAIN_FLAG_BACKUP_SEND) != 0)
else if ((flags & DSYNC_BRAIN_FLAG_BACKUP_RECV) != 0)
return brain;
}
struct dsync_brain *
{
struct dsync_ibc_settings ibc_set;
struct dsync_brain *brain;
return brain;
}
{
int ret;
i_error("Timeout during state=%s%s",
t_strdup_printf(" (send=%s recv=%s)",
}
/* unlink the lock file before it gets unlocked */
}
return ret;
}
static int
{
const char *home;
int ret;
/* locking done by remote */
return 0;
}
/* running dsync within the same server.
locking done by master brain. */
return 0;
}
i_error("Couldn't look up user's home dir");
return -1;
}
if (ret == 0) {
i_error("User has no home directory");
return -1;
}
for (;;) {
i_error("Couldn't create lock %s: %m",
return -1;
}
i_error("Couldn't lock %s: Timed out after %u seconds",
} else {
}
break;
}
break;
}
break;
}
/* success */
return 0;
}
/* file was recreated, try again */
}
return -1;
}
{
const struct dsync_ibc_settings *ibc_set;
return FALSE;
if (brain->lock_timeout > 0) {
return FALSE;
}
}
return TRUE;
}
{
const struct dsync_ibc_settings *ibc_set;
return FALSE;
if (ibc_set->lock_timeout > 0) {
return FALSE;
}
}
}
sizeof(brain->sync_box_guid));
else
return TRUE;
}
{
struct dsync_mailbox_state *state;
}
for (;;) {
if (ret == DSYNC_IBC_SEND_RET_FULL)
return;
break;
}
}
const struct dsync_mailbox_state *state)
{
struct dsync_mailbox_state *dupstate;
}
{
struct dsync_mailbox_state state;
enum dsync_ibc_recv_ret ret;
}
if (ret == DSYNC_IBC_RECV_RET_FINISHED) {
}
return changed;
}
{
return FALSE;
}
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
case DSYNC_STATE_SYNC_MAILS:
break;
case DSYNC_STATE_DONE:
break;
}
i_debug("brain %c: out state=%s changed=%d",
}
}
{
bool ret;
return FALSE;
}
T_BEGIN {
} T_END;
return ret;
}
{
struct hash_iterate_context *iter;
struct dsync_mailbox_node *node;
const struct dsync_mailbox_state *new_state;
struct dsync_mailbox_state *state;
/* update mailbox states */
else
}
/* remove nonexistent mailboxes */
guid);
}
}
{
}