changeset 218:e506203cffa4 HEAD

expunge() shouldn't update mmap, since we could be just going through the index records.
author Timo Sirainen <tss@iki.fi>
date Tue, 10 Sep 2002 06:40:58 +0300
parents b426c07093d3
children 79ae841efc11
files src/lib-index/mail-index.c
diffstat 1 files changed, 6 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index.c	Tue Sep 10 06:35:50 2002 +0300
+++ b/src/lib-index/mail-index.c	Tue Sep 10 06:40:58 2002 +0300
@@ -962,6 +962,7 @@
 
 	i_assert(!index->dirty_mmap);
 	i_assert(index->lock_type != MAIL_LOCK_UNLOCK);
+	i_assert(rec >= (MailIndexRecord *) index->mmap_base);
 
 	if (rec == NULL)
 		return NULL;
@@ -1235,20 +1236,18 @@
 
 static int mail_index_truncate(MailIndex *index)
 {
-	if (msync(index->mmap_base, index->mmap_length, MS_SYNC) == -1) {
-		index_set_error(index, "msync() failed for %s: %m",
-				index->filepath);
-		return FALSE;
-	}
+	off_t file_size;
 
 	/* truncate index file */
-	if (ftruncate(index->fd,
-		      (off_t)index->header->first_hole_position) < 0) {
+	file_size = (off_t)index->header->first_hole_position;
+	if (ftruncate(index->fd, file_size) < 0) {
 		index_set_error(index, "ftruncate() failed for index file "
 				"%s: %m", index->filepath);
 		return FALSE;
 	}
 
+	index->mmap_length = (size_t)file_size;
+
 	/* update header */
 	index->header->first_hole_position = 0;
 	index->header->first_hole_records = 0;
@@ -1260,10 +1259,6 @@
 			return FALSE;
 	}
 
-	index->dirty_mmap = TRUE;
-	if (!mmap_update(index))
-		return FALSE;
-
 	return TRUE;
 }