Skip to content

Commit

Permalink
lib-storage: If mail_index_header.first_recent_uid shrinks, reset \Re…
Browse files Browse the repository at this point in the history
…cent flags

This should never happen.
  • Loading branch information
sirainen committed Jul 18, 2017
1 parent caf029d commit e12a822
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib-storage/index/index-storage.h
Expand Up @@ -39,6 +39,7 @@ struct index_mailbox_context {

struct mailbox_vsize_update *vsize_update;

uint32_t recent_flags_prev_first_recent_uid;
uint32_t recent_flags_last_check_nextuid;

time_t sync_last_check;
Expand Down
9 changes: 9 additions & 0 deletions src/lib-storage/index/index-sync.c
Expand Up @@ -279,8 +279,17 @@ void index_sync_update_recent_count(struct mailbox *box)
uint32_t seq1, seq2;

hdr = mail_index_get_header(box->view);
if (hdr->first_recent_uid < ibox->recent_flags_prev_first_recent_uid) {
mail_storage_set_critical(box->storage,
"Mailbox %s: first_recent_uid unexpectedly shrank: %u -> %u",
box->vname, ibox->recent_flags_prev_first_recent_uid,
hdr->first_recent_uid);
mailbox_recent_flags_reset(box);
}

if (hdr->first_recent_uid > box->recent_flags_prev_uid ||
hdr->next_uid > ibox->recent_flags_last_check_nextuid) {
ibox->recent_flags_prev_first_recent_uid = hdr->first_recent_uid;
ibox->recent_flags_last_check_nextuid = hdr->next_uid;
if (mail_index_lookup_seq_range(box->view,
hdr->first_recent_uid,
Expand Down

0 comments on commit e12a822

Please sign in to comment.