dovecot-2.0: mdbox: Remove refcount=0 records from map index on ...

dovecot at dovecot.org dovecot at dovecot.org
Thu Aug 18 18:21:53 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.0/rev/1449a2e2c1f5
changeset: 12878:1449a2e2c1f5
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Aug 18 18:21:33 2011 +0300
description:
mdbox: Remove refcount=0 records from map index on the first purge (not second).

diffstat:

 src/lib-storage/index/dbox-multi/mdbox-purge.c |  14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diffs (47 lines):

diff -r 46bf11666cdd -r 1449a2e2c1f5 src/lib-storage/index/dbox-multi/mdbox-purge.c
--- a/src/lib-storage/index/dbox-multi/mdbox-purge.c	Tue Aug 16 22:36:23 2011 +0300
+++ b/src/lib-storage/index/dbox-multi/mdbox-purge.c	Thu Aug 18 18:21:33 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);


More information about the dovecot-cvs mailing list