Mercurial > dovecot > original-hg > dovecot-2.1
changeset 14922:cd413ab7aeb3
lib-storage: Fixed \Recent flag race conditions.
The \Recent flags should only be set while locked within
mail_index_sync_begin()..commit(). The following view syncing syncs only up
to how far the index was synced, so it won't see any new messages that
haven't yet been assigned a \Recent flag.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 24 Feb 2013 15:50:26 +0200 |
parents | e33fe1a7bb89 |
children | 10c1eb4ddef2 |
files | src/lib-storage/index/index-status.c |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-status.c Fri Feb 22 15:49:35 2013 +0200 +++ b/src/lib-storage/index/index-status.c Sun Feb 24 15:50:26 2013 +0200 @@ -48,9 +48,16 @@ hdr = mail_index_get_header(box->view); status_r->messages = hdr->messages_count; if ((items & STATUS_RECENT) != 0) { - /* make sure recent count is set, in case syncing hasn't - been done yet */ - index_sync_update_recent_count(box); + if ((box->flags & MAILBOX_FLAG_DROP_RECENT) != 0) { + /* recent flags are set and dropped by the previous + sync while index was locked. if we updated the + recent flags here we'd have a race condition. */ + i_assert(box->synced); + } else { + /* make sure recent count is set, in case we haven't + synced yet */ + index_sync_update_recent_count(box); + } status_r->recent = index_mailbox_get_recent_count(box); i_assert(status_r->recent <= status_r->messages); }