[dovecot-cvs] dovecot/src/lib-index mail-index-private.h, 1.49, 1.50 mail-index.c, 1.190, 1.191

cras at dovecot.org cras at dovecot.org
Sat Mar 5 21:19:27 EET 2005


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

Modified Files:
	mail-index-private.h mail-index.c 
Log Message:
Assert if mail_index_map() is called recursively.



Index: mail-index-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-private.h,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- mail-index-private.h	5 Mar 2005 19:13:24 -0000	1.49
+++ mail-index-private.h	5 Mar 2005 19:19:24 -0000	1.50
@@ -155,6 +155,7 @@
 	unsigned int readonly:1;
 	unsigned int fsck:1;
 	unsigned int sync_update:1;
+	unsigned int mapping:1;
 };
 
 enum mail_index_sync_handler_type {

Index: mail-index.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.190
retrieving revision 1.191
diff -u -d -r1.190 -r1.191
--- mail-index.c	5 Mar 2005 19:13:24 -0000	1.190
+++ mail-index.c	5 Mar 2005 19:19:24 -0000	1.191
@@ -845,17 +845,23 @@
 	struct mail_index_map *map;
 	int ret;
 
+	i_assert(!index->mapping);
 	i_assert(index->map == NULL || index->map->refcount > 0);
 	i_assert(index->lock_type != F_UNLCK);
 
+	index->mapping = TRUE;
+
 	if (!force && index->map != NULL) {
 		i_assert(index->hdr != NULL);
 		ret = mail_index_map_try_existing(index->map);
-		if (ret != 0)
+		if (ret != 0) {
+			index->mapping = FALSE;
 			return ret;
+		}
 
 		if (index->lock_type == F_WRLCK) {
 			/* we're syncing, don't break the mapping */
+			index->mapping = FALSE;
 			return 1;
 		}
 	}
@@ -900,22 +906,26 @@
 		ret = mail_index_read_map_with_retry(index, &map, force);
 	i_assert(index->map == NULL);
 
-	if (ret <= 0) {
-		mail_index_unmap_forced(index, map);
-		return ret;
+	if (ret > 0) {
+		ret = mail_index_check_header(index, map);
+		if (ret < 0)
+			ret = 0;
+		else if (ret == 0) {
+			index->fsck = TRUE;
+			ret = 1;
+		}
 	}
 
-	ret = mail_index_check_header(index, map);
-	if (ret < 0) {
+	if (ret <= 0) {
 		mail_index_unmap_forced(index, map);
-		return 0;
+		index->mapping = FALSE;
+		return ret;
 	}
-	if (ret == 0)
-		index->fsck = TRUE;
 
 	index->hdr = &map->hdr;
 	index->map = map;
 	i_assert(map->hdr.messages_count == map->records_count);
+	index->mapping = FALSE;
 	return 1;
 }
 



More information about the dovecot-cvs mailing list