dovecot: DEBUG: Verify header counters/lowwaters more often.
dovecot at dovecot.org
dovecot at dovecot.org
Wed Jun 20 01:56:47 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/bcf58c66a099
changeset: 5785:bcf58c66a099
user: Timo Sirainen <tss at iki.fi>
date: Wed Jun 20 01:54:42 2007 +0300
description:
DEBUG: Verify header counters/lowwaters more often.
diffstat:
3 files changed, 46 insertions(+), 31 deletions(-)
src/lib-index/mail-index-sync-private.h | 4 +++
src/lib-index/mail-index-sync-update.c | 35 ++++++++++++++++++++++++++++
src/lib-index/mail-index-view-sync.c | 38 +++++--------------------------
diffs (132 lines):
diff -r 9493c7f1ebca -r bcf58c66a099 src/lib-index/mail-index-sync-private.h
--- a/src/lib-index/mail-index-sync-private.h Wed Jun 20 01:34:18 2007 +0300
+++ b/src/lib-index/mail-index-sync-private.h Wed Jun 20 01:54:42 2007 +0300
@@ -87,4 +87,8 @@ void mail_index_sync_set_corrupted(struc
void mail_index_sync_set_corrupted(struct mail_index_sync_map_ctx *ctx,
const char *fmt, ...) __attr_format__(2, 3);
+#ifdef DEBUG
+void mail_index_map_check(struct mail_index_map *map);
#endif
+
+#endif
diff -r 9493c7f1ebca -r bcf58c66a099 src/lib-index/mail-index-sync-update.c
--- a/src/lib-index/mail-index-sync-update.c Wed Jun 20 01:34:18 2007 +0300
+++ b/src/lib-index/mail-index-sync-update.c Wed Jun 20 01:54:42 2007 +0300
@@ -654,6 +654,37 @@ static void mail_index_sync_update_hdr_d
}
}
}
+
+#ifdef DEBUG
+void mail_index_map_check(struct mail_index_map *map)
+{
+ const struct mail_index_header *hdr = &map->hdr;
+ unsigned int i, del = 0, recent = 0, seen = 0;
+
+ i_assert(hdr->messages_count == map->records_count);
+ for (i = 0; i < map->records_count; i++) {
+ const struct mail_index_record *rec;
+
+ rec = MAIL_INDEX_MAP_IDX(map, i);
+
+ if (rec->flags & MAIL_DELETED) {
+ i_assert(rec->uid >= hdr->first_deleted_uid_lowwater);
+ del++;
+ }
+ if (rec->flags & MAIL_RECENT) {
+ i_assert(rec->uid >= hdr->first_recent_uid_lowwater);
+ recent++;
+ }
+ if (rec->flags & MAIL_SEEN)
+ seen++;
+ else
+ i_assert(rec->uid >= hdr->first_unseen_uid_lowwater);
+ }
+ i_assert(del == hdr->deleted_messages_count);
+ i_assert(recent == hdr->recent_messages_count);
+ i_assert(seen == hdr->seen_messages_count);
+}
+#endif
int mail_index_sync_map(struct mail_index *index, struct mail_index_map **_map,
enum mail_index_sync_handler_type type, bool force)
@@ -765,6 +796,10 @@ int mail_index_sync_map(struct mail_inde
mail_index_sync_update_log_offset(&sync_map_ctx, view->map, TRUE);
+#ifdef DEBUG
+ mail_index_map_check(map);
+#endif
+
/* transaction log tracks internally the current tail offset.
besides using header updates, it also updates the offset to skip
over following external transactions to avoid extra unneeded log
diff -r 9493c7f1ebca -r bcf58c66a099 src/lib-index/mail-index-view-sync.c
--- a/src/lib-index/mail-index-view-sync.c Wed Jun 20 01:34:18 2007 +0300
+++ b/src/lib-index/mail-index-view-sync.c Wed Jun 20 01:54:42 2007 +0300
@@ -173,37 +173,15 @@ view_sync_get_expunges(struct mail_index
#ifdef DEBUG
static void mail_index_view_check(struct mail_index_view *view)
{
- unsigned int i, del = 0, recent = 0, seen = 0;
-
- i_assert(view->hdr.messages_count == view->map->records_count);
+ mail_index_map_check(view->map);
+
+ i_assert(view->hdr.messages_count == view->map->hdr.messages_count);
i_assert(view->hdr.deleted_messages_count ==
view->map->hdr.deleted_messages_count);
i_assert(view->hdr.recent_messages_count ==
view->map->hdr.recent_messages_count);
i_assert(view->hdr.seen_messages_count ==
view->map->hdr.seen_messages_count);
-
- for (i = 0; i < view->map->records_count; i++) {
- const struct mail_index_record *rec;
-
- rec = MAIL_INDEX_MAP_IDX(view->map, i);
-
- if (rec->flags & MAIL_DELETED) {
- i_assert(rec->uid >= view->hdr.first_deleted_uid_lowwater);
- del++;
- }
- if (rec->flags & MAIL_RECENT) {
- i_assert(rec->uid >= view->hdr.first_recent_uid_lowwater);
- recent++;
- }
- if (rec->flags & MAIL_SEEN)
- seen++;
- else
- i_assert(rec->uid >= view->hdr.first_unseen_uid_lowwater);
- }
- i_assert(del == view->hdr.deleted_messages_count);
- i_assert(recent == view->hdr.recent_messages_count);
- i_assert(seen == view->hdr.seen_messages_count);
}
#endif
@@ -277,12 +255,6 @@ int mail_index_view_sync_begin(struct ma
view->map->hdr = *hdr;
}
-#ifdef DEBUG
- i_assert(view->map->hdr.messages_count ==
- view->hdr.messages_count);
- mail_index_view_check(view);
-#endif
-
if (view->map->refcount > 1) {
map = mail_index_map_clone(view->map);
mail_index_unmap(view->index, &view->map);
@@ -293,6 +265,10 @@ int mail_index_view_sync_begin(struct ma
view->hdr = map->hdr;
i_assert(map->records_count == map->hdr.messages_count);
}
+
+#ifdef DEBUG
+ mail_index_view_check(view);
+#endif
/* Syncing the view invalidates all previous looked up records.
Unreference the mappings this view keeps because of them. */
More information about the dovecot-cvs
mailing list