if (mailbox_create(box, &update, FALSE) < 0) {
errstr = mailbox_get_last_internal_error(box, &error);
if (error != MAIL_ERROR_EXISTS) {
- i_error("Can't create mailbox %s: %s",
+ e_error(brain->event, "Can't create mailbox %s: %s",
mailbox_get_vname(box), errstr);
*error_r = error;
return -1;
}
/* sync the mailbox so we can look up its latest status */
if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) {
- i_error("Can't sync mailbox %s: %s",
+ e_error(brain->event, "Can't sync mailbox %s: %s",
mailbox_get_vname(box),
mailbox_get_last_internal_error(box, error_r));
return -1;
mismatching UIDVALIDITY is handled later, because we choose it by
checking which mailbox has more messages */
if (mailbox_get_metadata(box, MAILBOX_METADATA_GUID, &metadata) < 0) {
- i_error("Can't get mailbox GUID %s: %s",
+ e_error(brain->event, "Can't get mailbox GUID %s: %s",
mailbox_get_vname(box),
mailbox_get_last_internal_error(box, error_r));
return -1;
if ((ret > 0 && !brain->backup_recv &&
!brain->backup_send) || (ret != 0 && brain->backup_recv)) {
- if (brain->debug) {
- i_debug("brain %c: Changing mailbox %s GUID %s -> %s",
- brain->master_brain ? 'M' : 'S',
- mailbox_get_vname(box),
- guid_128_to_string(metadata.guid),
- guid_128_to_string(mailbox_guid));
- }
+ e_debug(brain->event, "Changing mailbox %s GUID %s -> %s",
+ mailbox_get_vname(box),
+ guid_128_to_string(metadata.guid),
+ guid_128_to_string(mailbox_guid));
i_zero(&update);
memcpy(update.mailbox_guid, mailbox_guid,
sizeof(update.mailbox_guid));
if (mailbox_update(box, &update) < 0) {
- i_error("Can't update mailbox GUID %s: %s",
+ e_error(brain->event, "Can't update mailbox GUID %s: %s",
mailbox_get_vname(box),
mailbox_get_last_internal_error(box, error_r));
return -1;
/* verify that the update worked */
if (mailbox_get_metadata(box, MAILBOX_METADATA_GUID,
&metadata) < 0) {
- i_error("Can't get mailbox GUID %s: %s",
+ e_error(brain->event, "Can't get mailbox GUID %s: %s",
mailbox_get_vname(box),
mailbox_get_last_internal_error(box, error_r));
return -1;
}
if (memcmp(mailbox_guid, metadata.guid,
sizeof(metadata.guid)) != 0) {
- i_error("Backend didn't update mailbox %s GUID",
+ e_error(brain->event,
+ "Backend didn't update mailbox %s GUID",
mailbox_get_vname(box));
*error_r = MAIL_ERROR_TEMP;
return -1;
}
} else if (ret < 0) {
- if (brain->debug) {
- i_debug("brain %c: Other brain should change mailbox "
- "%s GUID %s -> %s",
- brain->master_brain ? 'M' : 'S',
- mailbox_get_vname(box),
- guid_128_to_string(mailbox_guid),
- guid_128_to_string(metadata.guid));
- }
+ e_debug(brain->event,
+ "Other brain should change mailbox %s GUID %s -> %s",
+ mailbox_get_vname(box),
+ guid_128_to_string(mailbox_guid),
+ guid_128_to_string(metadata.guid));
}
return 0;
}
ret = dsync_brain_mailbox_alloc(brain, change->mailbox_guid,
&box, &errstr, error_r);
if (ret < 0) {
- i_error("Mailbox sync: Couldn't allocate mailbox %s GUID %s: %s",
+ e_error(brain->event,
+ "Mailbox sync: Couldn't allocate mailbox %s GUID %s: %s",
change->full_name,
guid_128_to_string(change->mailbox_guid), errstr);
return -1;
change->full_name, errstr));
return 0;
} else {
- i_error("Mailbox sync: mailbox_list_delete_dir failed: %s",
+ e_error(brain->event,
+ "Mailbox sync: mailbox_list_delete_dir failed: %s",
errstr);
*error_r = error;
return -1;
mailbox_get_vname(box), func_name, errstr));
ret = 0;
} else {
- i_error("Mailbox %s sync: %s failed: %s",
+ e_error(brain->event,
+ "Mailbox %s sync: %s failed: %s",
mailbox_get_vname(box), func_name, errstr);
*error_r = error;
}
for (ns = brain->user->namespaces; ns != NULL; ns = ns->next) {
if (!dsync_brain_want_namespace(brain, ns))
continue;
- if (brain->debug)
- i_debug("brain %c: Namespace %s has location %s",
- brain->master_brain ? 'M' : 'S',
- ns->prefix, ns->set->location);
+ e_debug(brain->event, "Namespace %s has location %s",
+ ns->prefix, ns->set->location);
if (dsync_mailbox_tree_fill(brain->local_mailbox_tree, ns,
brain->sync_box,
brain->sync_box_guid,
T_BEGIN {
const char *const *parts;
- if (brain->debug) {
- i_debug("brain %c: Local mailbox tree: %s %s",
- brain->master_brain ? 'M' : 'S', full_name,
- dsync_mailbox_node_to_string(node));
- }
+ e_debug(brain->event, "Local mailbox tree: %s %s",
+ full_name, dsync_mailbox_node_to_string(node));
parts = dsync_brain_mailbox_to_parts(brain, full_name);
ret = dsync_ibc_send_mailbox_tree_node(brain->ibc,
if (dsync_get_mailbox_name(brain, parts, &name, &ns) < 0)
return -1;
- if (brain->debug) {
- i_debug("brain %c: Remote mailbox tree: %s %s",
- brain->master_brain ? 'M' : 'S',
- t_strarray_join(parts, sep),
- dsync_mailbox_node_to_string(remote_node));
- }
+ e_debug(brain->event, "Remote mailbox tree: %s %s",
+ t_strarray_join(parts, sep),
+ dsync_mailbox_node_to_string(remote_node));
node = dsync_mailbox_tree_get(brain->remote_mailbox_tree, name);
node->ns = ns;
dsync_mailbox_node_copy_data(node, remote_node);
brain, parts, remote_node, sep);
} T_END;
if (ret2 < 0) {
- i_error("Couldn't find namespace for mailbox %s",
+ e_error(brain->event,
+ "Couldn't find namespace for mailbox %s",
t_strarray_join(parts, sep));
brain->failed = TRUE;
return TRUE;
if (dsync_mailbox_tree_build_guid_hash(brain->remote_mailbox_tree,
&dup_node1, &dup_node2) < 0) {
- i_error("Remote sent duplicate mailbox GUID %s for mailboxes %s and %s",
+ e_error(brain->event,
+ "Remote sent duplicate mailbox GUID %s for mailboxes %s and %s",
guid_128_to_string(dup_node1->mailbox_guid),
dsync_mailbox_node_get_full_name(brain->remote_mailbox_tree,
dup_node1),
if (brain->debug) {
const char *node_name = node == NULL ? "" :
dsync_mailbox_node_get_full_name(brain->local_mailbox_tree, node);
- i_debug("brain %c: Remote mailbox tree deletion: guid=%s type=%s timestamp=%ld name=%s local update=%s",
- brain->master_brain ? 'M' : 'S',
+ e_debug(brain->event,
+ "Remote mailbox tree deletion: guid=%s type=%s "
+ "timestamp=%ld name=%s local update=%s",
guid_128_to_string(deletes[i].guid),
dsync_mailbox_delete_type_to_string(deletes[i].type),
deletes[i].timestamp, node_name, status);
last_common_pvt_modseq,
&pvt_too_old);
if (ret < 0) {
- i_error("Failed to read transaction log for mailbox %s",
+ e_error(brain->event,
+ "Failed to read transaction log for mailbox %s",
mailbox_get_vname(brain->box));
brain->failed = TRUE;
return -1;
}
}
if (ret == 0) {
- i_warning("Failed to do incremental sync for mailbox %s, "
+ e_warning(brain->event,
+ "Failed to do incremental sync for mailbox %s, "
"retry with a full sync (%s)",
mailbox_get_vname(brain->box), desync_reason);
dsync_brain_set_changes_during_sync(brain, t_strdup_printf(
brain->sync_type == DSYNC_BRAIN_SYNC_TYPE_CHANGED);
if (dsync_mailbox_export_deinit(&brain->box_exporter,
&errstr, &error) < 0)
- i_error("Mailbox export failed: %s", errstr);
+ e_error(brain->event, "Mailbox export failed: %s", errstr);
}
if (brain->box_importer != NULL) {
uint32_t last_common_uid, last_messages_count;
mainly for invalid mbox files. */
return 0;
}
- i_error("Failed to access mailbox %s: %s",
+ e_error(box->event, "Failed to access mailbox %s: %s",
mailbox_get_vname(box), errstr);
*error_r = error;
return -1;
return -1;
}
if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) {
- i_error("Can't sync mailbox %s: %s",
+ e_error(brain->event, "Can't sync mailbox %s: %s",
mailbox_get_vname(box),
mailbox_get_last_internal_error(box, &brain->mail_error));
brain->failed = TRUE;
}
if (mailbox_update(box, &update) < 0) {
- i_error("Couldn't update mailbox %s metadata: %s",
+ e_error(brain->event, "Couldn't update mailbox %s metadata: %s",
mailbox_get_vname(box),
mailbox_get_last_internal_error(box, &brain->mail_error));
brain->failed = TRUE;
{
struct dsync_mailbox delete_box;
- if (brain->debug) {
- i_debug("brain %c: We don't have mailbox %s",
- brain->master_brain ? 'M' : 'S',
- guid_128_to_string(dsync_box->mailbox_guid));
- }
+ e_debug(brain->event, "We don't have mailbox %s",
+ guid_128_to_string(dsync_box->mailbox_guid));
i_zero(&delete_box);
memcpy(delete_box.mailbox_guid, dsync_box->mailbox_guid,
sizeof(delete_box.mailbox_guid));
if (dsync_brain_mailbox_alloc(brain, dsync_box->mailbox_guid,
&box, &errstr, &error) < 0) {
- i_error("Couldn't allocate mailbox GUID %s: %s",
+ e_error(brain->event, "Couldn't allocate mailbox GUID %s: %s",
guid_128_to_string(dsync_box->mailbox_guid), errstr);
brain->mail_error = error;
brain->failed = TRUE;
if (box == NULL) {
/* mailbox was probably deleted/renamed during sync */
if (brain->backup_send && brain->no_backup_overwrite) {
- if (brain->debug) {
- i_debug("brain %c: Ignore nonexistent "
- "mailbox GUID %s with -1 sync",
- brain->master_brain ? 'M' : 'S',
+ e_debug(brain->event,
+ "Ignore nonexistent mailbox GUID %s with -1 sync",
guid_128_to_string(dsync_box->mailbox_guid));
- }
dsync_brain_slave_send_mailbox_lost(brain, dsync_box, TRUE);
return TRUE;
}
return TRUE;
}
if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) {
- i_error("Can't sync mailbox %s: %s",
+ e_error(brain->event, "Can't sync mailbox %s: %s",
mailbox_get_vname(box),
mailbox_get_last_internal_error(box, &brain->mail_error));
file_lock_free(&lock);
return TRUE;
}
/* another process just deleted this mailbox? */
- if (brain->debug) {
- i_debug("brain %c: Skipping lost mailbox %s",
- brain->master_brain ? 'M' : 'S',
- guid_128_to_string(dsync_box->mailbox_guid));
- }
+ e_debug(brain->event, "Skipping lost mailbox %s",
+ guid_128_to_string(dsync_box->mailbox_guid));
dsync_brain_slave_send_mailbox_lost(brain, dsync_box, FALSE);
return TRUE;
}
if (!dsync_boxes_need_sync(brain, &local_dsync_box, dsync_box, &reason)) {
/* no fields appear to have changed, skip this mailbox */
- if (brain->debug) {
- i_debug("brain %c: Skipping unchanged mailbox %s",
- brain->master_brain ? 'M' : 'S',
- guid_128_to_string(dsync_box->mailbox_guid));
- }
+ e_debug(brain->event, "Skipping unchanged mailbox %s",
+ guid_128_to_string(dsync_box->mailbox_guid));
dsync_ibc_send_mailbox(brain->ibc, &local_dsync_box);
file_lock_free(&lock);
mailbox_free(&box);
return TRUE;
}
- if (brain->debug) {
- i_debug("brain %c: Syncing mailbox %s: %s",
- brain->master_brain ? 'M' : 'S',
- guid_128_to_string(dsync_box->mailbox_guid), reason);
- }
+ e_debug(brain->event, "Syncing mailbox %s: %s",
+ guid_128_to_string(dsync_box->mailbox_guid), reason);
/* start export/import */
dsync_brain_sync_mailbox_init(brain, box, lock, &local_dsync_box, FALSE);
if ((ret = dsync_ibc_recv_mailbox(brain->ibc, &dsync_box)) == 0)
return FALSE;
if (ret == DSYNC_IBC_RECV_RET_FINISHED) {
- i_error("Remote sent end-of-list instead of a mailbox");
+ e_error(brain->event, "Remote sent end-of-list instead of a mailbox");
brain->failed = TRUE;
return TRUE;
}
if (memcmp(dsync_box->mailbox_guid, brain->local_dsync_box.mailbox_guid,
sizeof(dsync_box->mailbox_guid)) != 0) {
- i_error("Remote sent mailbox with a wrong GUID");
+ e_error(brain->event, "Remote sent mailbox with a wrong GUID");
brain->failed = TRUE;
return TRUE;
}
if (dsync_box->mailbox_ignore) {
/* ignore this box */
- if (brain->debug)
- i_debug("brain %c: Ignoring missing remote box GUID %s",
- brain->master_brain ? 'M' : 'S',
- guid_128_to_string(dsync_box->mailbox_guid));
+ e_debug(brain->event, "Ignoring missing remote box GUID %s",
+ guid_128_to_string(dsync_box->mailbox_guid));
dsync_brain_sync_mailbox_deinit(brain);
return TRUE;
}
dsync_brain_sync_mailbox_deinit(brain);
return TRUE;
}
- if (brain->debug) {
- i_debug("brain %c: Syncing mailbox %s: %s",
- brain->master_brain ? 'M' : 'S',
- guid_128_to_string(dsync_box->mailbox_guid), reason);
- }
+ e_debug(brain->event, "Syncing mailbox %s: %s",
+ guid_128_to_string(dsync_box->mailbox_guid), reason);
if ((ret = dsync_brain_sync_mailbox_open(brain, dsync_box)) < 0)
return TRUE;
if (resync)
if (dsync_mailbox_export_deinit(&brain->box_exporter,
&errstr, &error) < 0) {
- i_error("Exporting mailbox %s failed: %s",
+ e_error(brain->event, "Exporting mailbox %s failed: %s",
mailbox_get_vname(brain->box), errstr);
brain->mail_error = error;
brain->failed = TRUE;
dsync_brain_sync_half_finished(brain);
return TRUE;
}
- if (brain->debug) {
- i_debug("brain %c: import mail uid %u guid %s",
- brain->master_brain ? 'M' : 'S', mail->uid, mail->guid);
- }
+ e_debug(brain->event, "import mail uid %u guid %s",
+ mail->uid, mail->guid);
if (dsync_mailbox_import_mail(brain->box_importer, mail) < 0)
brain->failed = TRUE;
i_stream_unref(&mail->input);
if ((ret = dsync_ibc_recv_mailbox_state(brain->ibc, &state)) == 0)
return FALSE;
if (ret == DSYNC_IBC_RECV_RET_FINISHED) {
- i_error("Remote sent end-of-list instead of a mailbox state");
+ e_error(brain->event,
+ "Remote sent end-of-list instead of a mailbox state");
brain->failed = TRUE;
return TRUE;
}
else if (dsync_mailbox_states_import(brain->mailbox_states, brain->pool,
set->state, &error) < 0) {
hash_table_clear(brain->mailbox_states, FALSE);
- i_error("Saved sync state is invalid, "
+ e_error(brain->event,
+ "Saved sync state is invalid, "
"falling back to full sync: %s", error);
brain->sync_type = sync_type = DSYNC_BRAIN_SYNC_TYPE_FULL;
} else {
- if (brain->debug) {
- i_debug("brain %c: Imported mailbox states:",
- brain->master_brain ? 'M' : 'S');
- dsync_brain_mailbox_states_dump(brain);
- }
+ e_debug(brain->event, "Imported mailbox states:");
+ dsync_brain_mailbox_states_dump(brain);
}
dsync_brain_mailbox_trees_init(brain);
storage = mail_namespace_get_default_storage(ns);
if (mail_storage_purge(storage) < 0) {
- i_error("Purging namespace '%s' failed: %s", ns->prefix,
+ e_error(brain->event,
+ "Purging namespace '%s' failed: %s", ns->prefix,
mail_storage_get_last_internal_error(storage, NULL));
}
}
*_brain = NULL;
if (dsync_ibc_has_timed_out(brain->ibc)) {
- i_error("Timeout during state=%s%s",
+ e_error(brain->event, "Timeout during state=%s%s",
dsync_state_names[brain->state],
brain->state != DSYNC_STATE_SYNC_MAILS ? "" :
t_strdup_printf(" (send=%s recv=%s)",
if (brain->lock_fd != -1) {
/* unlink the lock file before it gets unlocked */
i_unlink(brain->lock_path);
- if (brain->debug) {
- i_debug("brain %c: Unlocked %s",
- brain->master_brain ? 'M' : 'S',
- brain->lock_path);
- }
+ e_debug(brain->event, "Unlocked %s", brain->lock_path);
file_lock_free(&brain->lock);
i_close_fd(&brain->lock_fd);
}
if ((ret = strcmp(remote_hostname, local_hostname)) < 0) {
/* locking done by remote */
- if (brain->debug) {
- i_debug("brain %c: Locking done by remote "
- "(local hostname=%s, remote hostname=%s)",
- brain->master_brain ? 'M' : 'S',
- local_hostname, remote_hostname);
- }
+ e_debug(brain->event,
+ "Locking done by remote (local hostname=%s, remote hostname=%s)",
+ local_hostname, remote_hostname);
return 0;
}
if (ret == 0 && !brain->master_brain) {
/* running dsync within the same server.
locking done by master brain. */
- if (brain->debug) {
- i_debug("brain %c: Locking done by local master-brain "
- "(local hostname=%s, remote hostname=%s)",
- brain->master_brain ? 'M' : 'S',
- local_hostname, remote_hostname);
- }
+ e_debug(brain->event,
+ "Locking done by local master-brain (local hostname=%s, remote hostname=%s)",
+ local_hostname, remote_hostname);
return 0;
}
if ((ret = mail_user_get_home(brain->user, &home)) < 0) {
- i_error("Couldn't look up user's home dir");
+ e_error(brain->event, "Couldn't look up user's home dir");
return -1;
}
if (ret == 0) {
- i_error("User has no home directory");
+ e_error(brain->event, "User has no home directory");
return -1;
}
&brain->lock, &created, &error);
}
if (brain->lock_fd == -1)
- i_error("Couldn't lock %s: %s", brain->lock_path, error);
- else if (brain->debug) {
- i_debug("brain %c: Locking done locally in %s "
- "(local hostname=%s, remote hostname=%s)",
- brain->master_brain ? 'M' : 'S',
+ e_error(brain->event, "Couldn't lock %s: %s", brain->lock_path, error);
+ else {
+ e_debug(brain->event,
+ "Locking done locally in %s (local hostname=%s, remote hostname=%s)",
brain->lock_path, local_hostname, remote_hostname);
}
if (brain->verbose_proctitle)
ns = mail_namespace_find(brain->user->namespaces,
*prefixes);
if (ns == NULL) {
- i_error("Namespace not found: '%s'", *prefixes);
+ e_error(brain->event, "Namespace not found: '%s'", *prefixes);
brain->failed = TRUE;
return FALSE;
}
if (ret == DSYNC_IBC_RECV_RET_TRYAGAIN)
return FALSE;
if (error != NULL) {
- i_error("Remote dsync failed: %s", error);
+ e_error(brain->event, "Remote dsync failed: %s", error);
brain->failed = TRUE;
if (mail_error != 0 &&
(brain->mail_error == 0 || brain->mail_error == MAIL_ERROR_TEMP))
struct dsync_mailbox_state *state;
uint8_t *guid;
+ if (!event_want_debug(brain->event)) return;
+
iter = hash_table_iterate_init(brain->mailbox_states);
while (hash_table_iterate(iter, brain->mailbox_states, &guid, &state)) {
- i_debug("brain %c: Mailbox %s state: uidvalidity=%u uid=%u modseq=%"PRIu64" pvt_modseq=%"PRIu64" messages=%u changes_during_sync=%d",
- brain->master_brain ? 'M' : 'S',
+ e_debug(brain->event,
+ "Mailbox %s state: uidvalidity=%u uid=%u modseq=%"PRIu64" "
+ "pvt_modseq=%"PRIu64" messages=%u changes_during_sync=%d",
guid_128_to_string(guid),
state->last_uidvalidity,
state->last_common_uid,
guid);
if (node == NULL ||
node->existence != DSYNC_MAILBOX_NODE_EXISTS) {
- if (brain->debug) {
- i_debug("brain %c: Removed state for deleted mailbox %s",
- brain->master_brain ? 'M' : 'S',
- guid_128_to_string(guid));
- }
+ e_debug(brain->event,
+ "Removed state for deleted mailbox %s",
+ guid_128_to_string(guid));
hash_table_remove(brain->mailbox_states, guid);
}
}
hash_table_iterate_deinit(&iter);
- if (brain->debug) {
- i_debug("brain %c: Exported mailbox states:",
- brain->master_brain ? 'M' : 'S');
- dsync_brain_mailbox_states_dump(brain);
- }
+ e_debug(brain->event, "Exported mailbox states:");
+ dsync_brain_mailbox_states_dump(brain);
dsync_mailbox_states_export(brain->mailbox_states, output);
}
void dsync_brain_set_changes_during_sync(struct dsync_brain *brain,
const char *reason)
{
- if (brain->debug) {
- i_debug("brain %c: Change during sync: %s",
- brain->master_brain ? 'M' : 'S', reason);
- }
+ e_debug(brain->event, "Change during sync: %s", reason);
if (brain->changes_during_sync == NULL)
brain->changes_during_sync = p_strdup(brain->pool, reason);
}
struct dsync_mailbox_tree_sync_change *change;
const char *name;
- if ((ctx->sync_flags & DSYNC_MAILBOX_TREES_SYNC_FLAG_DEBUG) != 0 &&
- tree == ctx->local_tree) {
- i_debug("brain %c: Deleting mailbox '%s' (GUID %s): %s",
- (ctx->sync_flags & DSYNC_MAILBOX_TREES_SYNC_FLAG_MASTER_BRAIN) != 0 ? 'M' : 'S',
+ if (tree == ctx->local_tree) {
+ e_debug(ctx->event, "Deleting mailbox '%s' (GUID %s): %s",
dsync_mailbox_node_get_full_name(tree, node),
guid_128_to_string(node->mailbox_guid), reason);
}
remote_node, &reason);
}
/* handle children, if there are any */
- if (debug != NULL) {
- i_debug("brain %c: %s: %s",
- (ctx->sync_flags & DSYNC_MAILBOX_TREES_SYNC_FLAG_MASTER_BRAIN) != 0 ? 'M' : 'S',
- str_c(debug), reason);
- }
+ if (debug != NULL)
+ e_debug(ctx->event, "%s: %s", str_c(debug), reason);
if (!changed) T_BEGIN {
changed = sync_rename_mailboxes(ctx, local_node,
!node_has_existent_children(node, FALSE))) {
/* we can just delete this directory and
any child directories it may have */
- if ((ctx->sync_flags & DSYNC_MAILBOX_TREES_SYNC_FLAG_DEBUG) != 0) {
- i_debug("brain %c: %s mailbox %s: Delete directory-only tree",
- (ctx->sync_flags & DSYNC_MAILBOX_TREES_SYNC_FLAG_MASTER_BRAIN) != 0 ? 'M' : 'S',
- tree == ctx->local_tree ? "local" : "remote",
- dsync_mailbox_node_get_full_name(tree, node));
- }
+ e_debug(ctx->event, "%s mailbox %s: Delete directory-only tree",
+ tree == ctx->local_tree ? "local" : "remote",
+ dsync_mailbox_node_get_full_name(tree, node));
sync_rename_delete_node_dirs(ctx, tree, node);
} else {
T_BEGIN {
*renames_r = TRUE;
sync_rename_temp_mailbox_node(tree, node, &reason);
- if ((ctx->sync_flags & DSYNC_MAILBOX_TREES_SYNC_FLAG_DEBUG) != 0) {
- i_debug("brain %c: %s mailbox %s: %s",
- (ctx->sync_flags & DSYNC_MAILBOX_TREES_SYNC_FLAG_MASTER_BRAIN) != 0 ? 'M' : 'S',
- tree == ctx->local_tree ? "local" : "remote",
- dsync_mailbox_node_get_full_name(tree, node), reason);
- }
+ e_debug(ctx->event, "%s mailbox %s: %s",
+ tree == ctx->local_tree ? "local" : "remote",
+ dsync_mailbox_node_get_full_name(tree, node), reason);
} T_END;
return TRUE;
}
changed = sync_rename_mailboxes(ctx, &ctx->local_tree->root,
&ctx->remote_tree->root);
} T_END;
- if ((ctx->sync_flags & DSYNC_MAILBOX_TREES_SYNC_FLAG_DEBUG) != 0 &&
- changed) {
- i_debug("brain %c: -- Mailbox renamed, restart sync --",
- (ctx->sync_flags & DSYNC_MAILBOX_TREES_SYNC_FLAG_MASTER_BRAIN) != 0 ? 'M' : 'S');
- }
+ if (changed)
+ e_debug(ctx->event, "-- Mailbox renamed, restart sync --");
+
} while (changed && ++count <= max_renames);
if (changed) {
- i_error("BUG: Mailbox renaming algorithm got into a potentially infinite loop, aborting");
+ e_debug(ctx->event,
+ "BUG: Mailbox renaming algorithm got into a potentially infinite loop, aborting");
return -1;
}
/* Make sure the mailbox is open - locking requires it */
if (mailbox_open(box) < 0) {
- i_error("Can't open mailbox %s: %s", mailbox_get_vname(box),
+ e_error(brain->event,
+ "Can't open mailbox %s: %s", mailbox_get_vname(box),
mailbox_get_last_internal_error(box, &brain->mail_error));
return -1;
}
ret = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX, &path);
if (ret < 0) {
- i_error("Can't get mailbox %s path: %s", mailbox_get_vname(box),
+ e_error(brain->event,
+ "Can't get mailbox %s path: %s", mailbox_get_vname(box),
mailbox_get_last_internal_error(box, &brain->mail_error));
return -1;
}
if (mailbox_lock_file_create(box, DSYNC_MAILBOX_LOCK_FILENAME,
brain->mailbox_lock_timeout_secs,
lock_r, &error) <= 0) {
- i_error("Failed to lock mailbox %s for dsyncing: %s",
+ e_error(brain->event,
+ "Failed to lock mailbox %s for dsyncing: %s",
box->vname, error);
return -1;
}