Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7567:9c0d2413735d HEAD
Sort index: Handle reset_id growing while adding non-wanted messages to sort
list.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 29 May 2008 16:29:35 +0300 |
parents | 8ae86f73f80d |
children | 66e6b61680a5 |
files | src/lib-storage/index/index-sort-string.c |
diffstat | 1 files changed, 19 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-sort-string.c Thu May 29 07:05:18 2008 +0300 +++ b/src/lib-storage/index/index-sort-string.c Thu May 29 16:29:35 2008 +0300 @@ -36,6 +36,8 @@ uint32_t ext_id, last_seq, highest_reset_id; unsigned int regetting:1; + unsigned int have_all_wanted:1; + unsigned int no_writing:1; }; static char expunged_msg; @@ -164,12 +166,18 @@ ctx->ext_id, &reset_id)) reset_id = 0; if (reset_id != ctx->highest_reset_id) { - if (reset_id > ctx->highest_reset_id) { + if (reset_id < ctx->highest_reset_id) { + i_assert(expunged); + node->sort_id = 0; + } else if (ctx->have_all_wanted) { + /* a bit late to start changing the reset_id. + the node lists aren't ordered by sequence + anymore. */ + node->sort_id = 0; + ctx->no_writing = TRUE; + } else { ctx->highest_reset_id = reset_id; index_sort_reget_sort_ids(ctx); - } else { - i_assert(expunged); - node->sort_id = 0; } } } @@ -599,6 +607,12 @@ const struct mail_sort_node *nodes; unsigned int i, count; + if (ctx->no_writing) { + /* our reset_id is already stale - don't even bother + trying to write */ + return; + } + mail_index_ext_reset_inc(t->trans, ext_id, ctx->highest_reset_id, FALSE); /* add the missing sort IDs to index */ @@ -635,6 +649,7 @@ unsigned int i, count; uint32_t seq, next_seq; + ctx->have_all_wanted = TRUE; seqs = array_get(&ctx->program->seqs, &count); for (i = 0, next_seq = 1; i < count; i++) {