Mercurial > dovecot > core-2.2
changeset 13276:c7fa03ee87c8
mdbox: Remove refcount=0 records from map index on the first purge (not second).
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 18 Aug 2011 18:20:08 +0300 |
parents | e538fa0bdcbb |
children | 030e33bde821 |
files | src/lib-storage/index/dbox-multi/mdbox-purge.c |
diffstat | 1 files changed, 8 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/dbox-multi/mdbox-purge.c Thu Aug 18 18:12:59 2011 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-purge.c Thu Aug 18 18:20:08 2011 +0300 @@ -291,7 +291,8 @@ } static int -mdbox_file_purge(struct mdbox_purge_context *ctx, struct dbox_file *file) +mdbox_file_purge(struct mdbox_purge_context *ctx, struct dbox_file *file, + uint32_t file_id) { struct mdbox_storage *dstorage = (struct mdbox_storage *)file->storage; struct stat st; @@ -326,8 +327,7 @@ /* get list of map UIDs that exist in this file (again has to be done after locking) */ i_array_init(&msgs_arr, 128); - if (mdbox_map_get_file_msgs(dstorage->map, - ((struct mdbox_file *)file)->file_id, + if (mdbox_map_get_file_msgs(dstorage->map, file_id, &msgs_arr) < 0) { array_free(&msgs_arr); dbox_file_unlock(file); @@ -420,10 +420,12 @@ /* unlink only after unlocking map, so readers don't see it temporarily vanished */ - if (ret > 0) + if (ret > 0) { (void)dbox_file_unlink(file); - else + mdbox_map_remove_file_id(ctx->storage->map, file_id); + } else { dbox_file_unlock(file); + } array_free(&copied_map_uids); array_free(&expunged_map_uids); @@ -664,7 +666,7 @@ seq_range_array_iter_nth(&iter, i++, &file_id)) T_BEGIN { file = mdbox_file_init(storage, file_id); if (dbox_file_open(file, &deleted) > 0 && !deleted) { - if (mdbox_file_purge(ctx, file) < 0) + if (mdbox_file_purge(ctx, file, file_id) < 0) ret = -1; } else { mdbox_map_remove_file_id(storage->map, file_id);