dovecot-2.2: dsync: Improved unexpected error logging.
dovecot at dovecot.org
dovecot at dovecot.org
Sun Feb 17 10:15:10 EET 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/9c095a50ba3e
changeset: 15819:9c095a50ba3e
user: Timo Sirainen <tss at iki.fi>
date: Sun Feb 17 10:14:49 2013 +0200
description:
dsync: Improved unexpected error logging.
diffstat:
src/doveadm/dsync/dsync-mailbox-import.c | 38 ++++++++++++++++++++++---------
1 files changed, 27 insertions(+), 11 deletions(-)
diffs (105 lines):
diff -r e07a8b17af8b -r 9c095a50ba3e src/doveadm/dsync/dsync-mailbox-import.c
--- a/src/doveadm/dsync/dsync-mailbox-import.c Sun Feb 17 10:11:20 2013 +0200
+++ b/src/doveadm/dsync/dsync-mailbox-import.c Sun Feb 17 10:14:49 2013 +0200
@@ -3,6 +3,7 @@
#include "lib.h"
#include "array.h"
#include "hash.h"
+#include "hex-binary.h"
#include "istream.h"
#include "seq-range-array.h"
#include "mail-storage-private.h"
@@ -214,18 +215,29 @@
static bool
dsync_mail_change_guid_equals(const struct dsync_mail_change *change,
- const char *guid)
+ const char *guid, const char **cmp_guid_r)
{
guid_128_t guid_128, change_guid_128;
- if (change->type != DSYNC_MAIL_CHANGE_TYPE_EXPUNGE)
+ if (change->type != DSYNC_MAIL_CHANGE_TYPE_EXPUNGE) {
+ if (cmp_guid_r != NULL)
+ *cmp_guid_r = change->guid;
return strcmp(change->guid, guid) == 0;
+ }
if (guid_128_from_string(change->guid, change_guid_128) < 0)
i_unreached();
mail_generate_guid_128_hash(guid, guid_128);
- return memcmp(change_guid_128, guid_128, GUID_128_SIZE) == 0;
+ if (memcmp(change_guid_128, guid_128, GUID_128_SIZE) != 0) {
+ if (cmp_guid_r != NULL) {
+ *cmp_guid_r = t_strdup_printf("%s(expunged, orig=%s)",
+ binary_to_hex(change_guid_128, sizeof(change_guid_128)),
+ change->guid);
+ }
+ return FALSE;
+ }
+ return TRUE;
}
static int
@@ -478,7 +490,7 @@
dsync_import_set_mail(struct dsync_mailbox_importer *importer,
const struct dsync_mail_change *change)
{
- const char *guid;
+ const char *guid, *cmp_guid;
if (!mail_set_uid(importer->mail, change->uid))
return FALSE;
@@ -498,10 +510,10 @@
dsync_mail_error(importer, importer->mail, "GUID");
return FALSE;
}
- if (!dsync_mail_change_guid_equals(change, guid)) {
+ if (!dsync_mail_change_guid_equals(change, guid, &cmp_guid)) {
dsync_import_unexpected_state(importer, t_strdup_printf(
"Unexpected GUID mismatch for UID=%u: %s != %s",
- change->uid, guid, change->guid));
+ change->uid, guid, cmp_guid));
importer->failed = TRUE;
return FALSE;
}
@@ -511,12 +523,14 @@
static bool dsync_check_cur_guid(struct dsync_mailbox_importer *importer,
const struct dsync_mail_change *change)
{
+ const char *cmp_guid;
+
if (change->guid == NULL || *change->guid == '\0')
return TRUE;
- if (!dsync_mail_change_guid_equals(change, importer->cur_guid)) {
+ if (!dsync_mail_change_guid_equals(change, importer->cur_guid, &cmp_guid)) {
dsync_import_unexpected_state(importer, t_strdup_printf(
"Unexpected GUID mismatch (2) for UID=%u: %s != %s",
- change->uid, importer->cur_guid, change->guid));
+ change->uid, importer->cur_guid, cmp_guid));
importer->failed = TRUE;
return FALSE;
}
@@ -1027,8 +1041,10 @@
if (*change->guid != '\0' && *importer->cur_guid != '\0') {
/* we have GUIDs, verify them */
- return dsync_mail_change_guid_equals(change,
- importer->cur_guid) ? 1 : 0;
+ if (dsync_mail_change_guid_equals(change, importer->cur_guid, NULL))
+ return 1;
+ else
+ return 0;
}
/* verify hdr_hash if it exists */
@@ -1069,7 +1085,7 @@
return FALSE;
i_assert(local_change->type == DSYNC_MAIL_CHANGE_TYPE_EXPUNGE);
- if (dsync_mail_change_guid_equals(local_change, change->guid))
+ if (dsync_mail_change_guid_equals(local_change, change->guid, NULL))
importer->last_common_uid = change->uid;
else if (change->type != DSYNC_MAIL_CHANGE_TYPE_EXPUNGE)
dsync_mailbox_common_uid_found(importer);
More information about the dovecot-cvs
mailing list