Mercurial > dovecot > original-hg > dovecot-1.2
changeset 5271:239fe5057748 HEAD
View syncing fixes.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 10 Mar 2007 20:48:49 +0200 |
parents | 6664699c1f2d |
children | 82b4a055e109 |
files | src/lib-index/mail-index-sync-update.c src/lib-index/mail-index-view-sync.c |
diffstat | 2 files changed, 32 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-index-sync-update.c Sat Mar 10 20:46:56 2007 +0200 +++ b/src/lib-index/mail-index-sync-update.c Sat Mar 10 20:48:49 2007 +0200 @@ -35,9 +35,11 @@ prev_offset = ctx->ext_intro_offset; } - if (!ctx->sync_only_external) + if (!ctx->sync_only_external) { + i_assert(prev_offset >= map->hdr.log_file_int_offset || + prev_seq > map->hdr.log_file_seq); map->hdr.log_file_int_offset = prev_offset; - else if (map->hdr.log_file_seq != prev_seq) { + } else if (map->hdr.log_file_seq != prev_seq) { /* log sequence changed. update internal offset to beginning of the new file. */ i_assert(map->hdr.log_file_int_offset == @@ -45,8 +47,17 @@ map->hdr.log_file_int_offset = ctx->view->index->log->head->hdr.hdr_size; } - map->hdr.log_file_seq = prev_seq; - map->hdr.log_file_ext_offset = prev_offset; + + /* we might be in the middle of syncing internal transactions, with + some of the following external transactions already synced. */ + i_assert(prev_seq > map->hdr.log_file_seq || + prev_offset >= map->hdr.log_file_ext_offset || + (!eol && !ctx->sync_only_external)); + if (map->hdr.log_file_seq != prev_seq || + prev_offset > map->hdr.log_file_ext_offset) { + map->hdr.log_file_seq = prev_seq; + map->hdr.log_file_ext_offset = prev_offset; + } } static int
--- a/src/lib-index/mail-index-view-sync.c Sat Mar 10 20:46:56 2007 +0200 +++ b/src/lib-index/mail-index-view-sync.c Sat Mar 10 20:48:49 2007 +0200 @@ -395,7 +395,7 @@ uint32_t seq; uoff_t offset; int ret; - bool skipped; + bool skipped, synced_to_map; for (;;) { /* Get the next transaction from log. */ @@ -441,6 +441,15 @@ offset); } + /* if we started from a map that we didn't create ourself, + some of the external transactions may already be synced. + at the end of view sync we'll update the ext_offset in the + header so that this check always becomes FALSE for + subsequent syncs. */ + synced_to_map = offset < view->hdr.log_file_ext_offset && + seq == view->hdr.log_file_seq && + (ctx->hdr->type & MAIL_TRANSACTION_EXTERNAL) != 0; + /* Apply transaction to view's mapping if needed (meaning we didn't just re-map the view to head mapping). */ if (ctx->sync_map_update) { @@ -635,6 +644,13 @@ view->map = view->sync_new_map; view->sync_new_map = NULL; } + + if (ctx->sync_map_update) { + view->map->hdr.log_file_seq = view->log_file_seq; + view->map->hdr.log_file_int_offset = + view->map->hdr.log_file_ext_offset = + view->log_file_offset; + } view->hdr = view->map->hdr; #ifdef DEBUG