changeset 2043:4548def7ac02 HEAD

Don't try to re-map dirty memory mapping.
author Timo Sirainen <tss@iki.fi>
date Sun, 23 May 2004 19:29:35 +0300
parents 418a0de45c38
children d2eafac70369
files src/lib-index/mail-index.c
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index.c	Sun May 23 05:18:27 2004 +0300
+++ b/src/lib-index/mail-index.c	Sun May 23 19:29:35 2004 +0300
@@ -134,6 +134,8 @@
 	const struct mail_index_header *hdr;
 	unsigned int records_count;
 
+	i_assert(map->buffer == NULL);
+
 	map->mmap_base = index->lock_type != F_WRLCK ?
 		mmap_ro_file(index->fd, &map->mmap_size) :
 		mmap_rw_file(index->fd, &map->mmap_size);
@@ -185,6 +187,8 @@
 	ssize_t ret;
 	size_t pos, records_size;
 
+	i_assert(map->mmap_base == NULL);
+
 	memset(&hdr, 0, sizeof(hdr));
 
 	ret = 1;
@@ -272,6 +276,12 @@
 
 	map = index->map;
 	if (map != NULL && MAIL_INDEX_MAP_IS_IN_MEMORY(map)) {
+		if (map->write_to_disk) {
+			/* we have modified this mapping and it's waiting to
+			   be written to disk once we drop exclusive lock.
+			   mapping couldn't have changed, so do nothing. */
+			return 1;
+		}
 		/* FIXME: we need to re-read header */
 	} else if (map != NULL) {
 		/* see if re-mmaping is needed (file has grown) */