changeset 4662:d021f2b0ded2 HEAD

Handle moving to memory failures better so we won't crash in some situations.
author Timo Sirainen <tss@iki.fi>
date Fri, 13 Oct 2006 21:42:50 +0300
parents 885bef091d1a
children ebbc7cd727cd
files src/lib-index/mail-index-private.h src/lib-index/mail-index.c
diffstat 2 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-private.h	Fri Oct 13 21:03:22 2006 +0300
+++ b/src/lib-index/mail-index-private.h	Fri Oct 13 21:42:50 2006 +0300
@@ -27,7 +27,7 @@
 	((index)->dir == NULL)
 
 #define MAIL_INDEX_MAP_IS_IN_MEMORY(map) \
-	((map) != NULL && (map)->buffer != NULL)
+	((map)->buffer != NULL)
 
 #define MAIL_INDEX_MAP_IDX(map, idx) \
 	((struct mail_index_record *) \
--- a/src/lib-index/mail-index.c	Fri Oct 13 21:03:22 2006 +0300
+++ b/src/lib-index/mail-index.c	Fri Oct 13 21:42:50 2006 +0300
@@ -1797,9 +1797,6 @@
 	if (MAIL_INDEX_IS_IN_MEMORY(index))
 		return 0;
 
-	/* set the index as being into memory */
-	i_free_and_null(index->dir);
-
 	if (index->map == NULL) {
 		/* mbox file was never even opened. just mark it as being in
 		   memory and let the caller re-open the index. */
@@ -1807,6 +1804,9 @@
 		return -1;
 	}
 
+	/* set the index as being into memory */
+	i_free_and_null(index->dir);
+
 	/* move index map to memory */
 	map = mail_index_map_clone(index->map, index->map->hdr.record_size);
 	mail_index_unmap(index, &index->map);
@@ -1833,7 +1833,7 @@
 
 	mail_index_set_inconsistent(index);
 
-	if (index->readonly)
+	if (index->readonly || index->map == NULL)
 		return;
 
 	hdr = *index->hdr;