[dovecot-cvs] dovecot/src/lib-index mailbox-list-index-sync.c, 1.11, 1.12

tss at dovecot.org tss at dovecot.org
Fri Mar 16 02:33:54 EET 2007


Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv32467

Modified Files:
	mailbox-list-index-sync.c 
Log Message:
deleted_space wasn't being calculated, so the index was never compressed.



Index: mailbox-list-index-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mailbox-list-index-sync.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- mailbox-list-index-sync.c	16 Mar 2007 00:18:13 -0000	1.11
+++ mailbox-list-index-sync.c	16 Mar 2007 00:33:52 -0000	1.12
@@ -502,7 +502,7 @@
 
 	/* count how much space we need and how much we wasted for deleted
 	   records */
-	nondeleted_count = 0; space_needed = 0; deleted_space = 0;
+	nondeleted_count = 0; space_needed = 0;
 	sync_recs = array_get_modifiable(&sync_dir->records, &count);
 	for (src = 0; src < count; src++) {
 		if (sync_recs[src].seen || partial) {
@@ -511,9 +511,6 @@
 				/* new record */
 				space_needed += strlen(sync_recs[src].name) + 1;
 			}
-		} else {
-			deleted_space += sizeof(*new_recs) +
-				strlen(sync_recs[src].name) + 1;
 		}
 	}
 
@@ -528,6 +525,7 @@
 	if (sync_dir->offset == 0) {
 		dir = NULL;
 		recs = NULL;
+		deleted_space = 0;
 	} else {
 		/* the offset should have been verified already to be valid */
 		i_assert(sync_dir->offset == offset_pos);
@@ -535,6 +533,10 @@
 		dir = CONST_PTR_OFFSET(index->const_mmap_base,
 				       sync_dir->offset);
 		recs = MAILBOX_LIST_RECORDS(dir);
+
+		/* approximate deleted_space. some of the mailbox names will be
+		   reused, but don't bother calculating them. */
+		deleted_space = sizeof(*dir) + dir->dir_size;
 	}
 
 	new_dir = base;
@@ -627,6 +629,7 @@
 		index->hdr = index->const_mmap_base;
 	}
 
+	ctx->hdr.deleted_space += deleted_space;
 	sync_dir->offset = base_offset;
 	return 0;
 }



More information about the dovecot-cvs mailing list