[dovecot-cvs] dovecot/src/lib-index mail-index.c,1.116,1.117

cras at procontrol.fi cras at procontrol.fi
Sat May 1 21:30:37 EEST 2004


Update of /home/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv20958/lib-index

Modified Files:
	mail-index.c 
Log Message:
syncing fix



Index: mail-index.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -d -r1.116 -r1.117
--- mail-index.c	1 May 2004 16:42:10 -0000	1.116
+++ mail-index.c	1 May 2004 18:30:35 -0000	1.117
@@ -261,19 +261,25 @@
 
 int mail_index_map(struct mail_index *index, int force)
 {
+	const struct mail_index_header *hdr;
 	struct mail_index_map *map;
+	size_t used_size;
 	int ret;
 
-	if (index->map != NULL) {
-		map = index->map;
-		if (map != NULL && !force)
+	map = index->map;
+	if (map != NULL && MAIL_INDEX_MAP_IS_IN_MEMORY(map)) {
+		/* FIXME: we need to re-read header */
+	} else if (map != NULL) {
+		/* see if re-mmaping is needed (file has grown) */
+		hdr = map->mmap_base;
+                used_size = hdr->header_size +
+			hdr->messages_count * sizeof(struct mail_index_record);
+		if (map->mmap_size >= used_size && !force)
 			return 1;
 
-		if (map->mmap_base != NULL) {
-			if (munmap(map->mmap_base, map->mmap_size) < 0)
-				mail_index_set_syscall_error(index, "munmap()");
-			map->mmap_base = NULL;
-		}
+		if (munmap(map->mmap_base, map->mmap_size) < 0)
+			mail_index_set_syscall_error(index, "munmap()");
+		map->mmap_base = NULL;
 	} else {
 		map = i_new(struct mail_index_map, 1);
 		map->refcount = 1;



More information about the dovecot-cvs mailing list