[dovecot-cvs] dovecot/src/lib-index mail-index.c,1.112,1.113

cras at procontrol.fi cras at procontrol.fi
Fri Apr 30 23:17:18 EEST 2004


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

Modified Files:
	mail-index.c 
Log Message:
changes



Index: mail-index.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -d -r1.112 -r1.113
--- mail-index.c	29 Apr 2004 00:08:00 -0000	1.112
+++ mail-index.c	30 Apr 2004 20:17:15 -0000	1.113
@@ -177,23 +177,20 @@
 			       struct mail_index_map *map)
 {
 	struct mail_index_header hdr;
-	void *data;
+	void *data = NULL;
 	ssize_t ret;
 	size_t pos, records_size;
 
-	do {
-		memset(&hdr, 0, sizeof(hdr));
-
-		ret = 1;
-		for (pos = 0; ret > 0 && pos < sizeof(hdr); ) {
-			ret = pread(index->fd, PTR_OFFSET(&hdr, pos),
-				    sizeof(hdr) - pos, pos);
-			if (ret > 0)
-				pos += ret;
-		}
-		if (ret < 0 || pos < MAIL_INDEX_HEADER_MIN_SIZE)
-			break;
+	memset(&hdr, 0, sizeof(hdr));
 
+	ret = 1;
+	for (pos = 0; ret > 0 && pos < sizeof(hdr); ) {
+		ret = pread(index->fd, PTR_OFFSET(&hdr, pos),
+			    sizeof(hdr) - pos, pos);
+		if (ret > 0)
+			pos += ret;
+	}
+	if (ret >= 0 && pos >= MAIL_INDEX_HEADER_MIN_SIZE) {
 		records_size = hdr.messages_count *
 			sizeof(struct mail_index_record);
 
@@ -209,7 +206,7 @@
 
 		ret = pread_full(index->fd, data, records_size,
 				 hdr.header_size);
-	} while (0);
+	}
 
 	if (ret < 0) {
 		if (errno == ESTALE)
@@ -265,25 +262,12 @@
 int mail_index_map(struct mail_index *index, int force)
 {
 	struct mail_index_map *map;
-	size_t used_size;
 	int ret;
 
-	if (index->map != NULL && MAIL_INDEX_MAP_IS_IN_MEMORY(index->map)) {
-		/* FIXME: can we avoid reading it? */
-		map = index->map;
-	} else if (index->map != NULL) {
+	if (index->map != NULL) {
 		map = index->map;
-
-		/* see if re-mmaping is needed (file has grown) */
-                used_size = map->hdr->header_size +
-			map->hdr->messages_count *
-			sizeof(struct mail_index_record);
-		if (map->mmap_size >= used_size && !force) {
-			/* update log file position in case it has changed */
-			map->log_file_seq = map->hdr->log_file_seq;
-			map->log_file_offset = map->hdr->log_file_offset;
+		if (map != NULL && !force)
 			return 1;
-		}
 
 		if (map->mmap_base != NULL) {
 			if (munmap(map->mmap_base, map->mmap_size) < 0)



More information about the dovecot-cvs mailing list