? diff ? dovecot.index.log ? idx ? idx2 ? idxview ? idxview.c ? logview ? logview.c ? mail-cache-debug.diff ? mail-cache-uid.diff ? x Index: mail-index-fsck.c =================================================================== RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-fsck.c,v retrieving revision 1.30 diff -u -r1.30 mail-index-fsck.c --- mail-index-fsck.c 13 Jan 2006 20:26:13 -0000 1.30 +++ mail-index-fsck.c 3 May 2006 19:40:55 -0000 @@ -138,6 +138,8 @@ int ret; bool lock_log; + abort(); + if (index->sync_update) { /* we're modifying index, don't do anything */ return 1; Index: mail-index-sync-update.c =================================================================== RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync-update.c,v retrieving revision 1.95 diff -u -r1.95 mail-index-sync-update.c --- mail-index-sync-update.c 2 May 2006 22:06:32 -0000 1.95 +++ mail-index-sync-update.c 3 May 2006 19:40:55 -0000 @@ -50,6 +50,7 @@ mail_index_set_error(index, "Recent counter wrong in index file %s", index->filepath); + abort(); } else if (--hdr->recent_messages_count == 0) hdr->first_recent_uid_lowwater = hdr->next_uid; } @@ -63,6 +64,7 @@ mail_index_set_error(index, "Seen counter wrong in index file %s", index->filepath); + abort(); } else if (++hdr->seen_messages_count == hdr->messages_count) hdr->first_unseen_uid_lowwater = hdr->next_uid; } @@ -77,6 +79,7 @@ mail_index_set_error(index, "Deleted counter wrong in index file %s", index->filepath); + abort(); } else if (--hdr->deleted_messages_count == 0) hdr->first_deleted_uid_lowwater = hdr->next_uid; } @@ -105,6 +108,33 @@ view->broken_counters = FALSE; } +static void check_counts(struct mail_index_view *view) +{ + struct mail_index_map *map = view->map; + const struct mail_index_record *rec; + struct mail_index_header hdr; + unsigned int i; + + if (view->broken_counters) + return; + + memset(&hdr, 0, sizeof(hdr)); + hdr.messages_count = view->hdr.messages_count; + + for (i = 0; i < view->hdr.messages_count; i++) { + rec = MAIL_INDEX_MAP_IDX(map, i); + mail_index_header_update_counts(view->index, &hdr, + 0, rec->flags); + } + + if (hdr.recent_messages_count != map->hdr.recent_messages_count) + i_panic("recent count differs"); + if (hdr.seen_messages_count != map->hdr.seen_messages_count) + i_panic("seen count differs"); + if (hdr.deleted_messages_count != map->hdr.deleted_messages_count) + i_panic("deleted count differs"); +} + static void mail_index_header_update_lowwaters(struct mail_index_header *hdr, const struct mail_index_record *rec) @@ -158,6 +188,8 @@ if (seq1 == 0) return 1; + check_counts(view); + /* don't call expunge handlers if we're syncing view */ if (ctx->type != MAIL_INDEX_SYNC_HANDLER_VIEW && !ctx->expunge_handlers_set) @@ -224,6 +267,8 @@ return -1; } + check_counts(view); + if (MAIL_INDEX_MAP_IS_IN_MEMORY(map)) { i_assert(map->records_count * map->hdr.record_size == buffer_get_used_size(map->buffer)); @@ -302,6 +346,7 @@ mail_index_header_update_lowwaters(hdr, rec); } } else { + check_counts(view); for (idx = seq1-1; idx < seq2; idx++) { rec = MAIL_INDEX_MAP_IDX(view->map, idx); @@ -312,6 +357,7 @@ old_flags, rec->flags); mail_index_header_update_lowwaters(hdr, rec); } + check_counts(view); } return 1; } @@ -793,6 +842,8 @@ i_assert(view->map == index->map); view->hdr = map->hdr; + check_counts(view); + mail_index_view_unlock(view); return ret; }