dovecot-2.2: lib-index: Fixed assert-crash caused by recent cach...

dovecot at dovecot.org dovecot at dovecot.org
Sat Jan 5 01:14:34 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/348e9bad84f0
changeset: 15537:348e9bad84f0
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Nov 28 03:56:06 2012 +0200
description:
lib-index: Fixed assert-crash caused by recent cache file changes.

diffstat:

 src/lib-index/mail-cache.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (46 lines):

diff -r e62938129955 -r 348e9bad84f0 src/lib-index/mail-cache.c
--- a/src/lib-index/mail-cache.c	Wed Nov 28 03:55:25 2012 +0200
+++ b/src/lib-index/mail-cache.c	Wed Nov 28 03:56:06 2012 +0200
@@ -281,6 +281,7 @@
 				!MAIL_CACHE_IS_UNUSABLE(cache) &&
 				cache->hdr->file_seq != 0 ?
 				cache->hdr->file_seq : 0;
+			cache->hdr = NULL;
 			return -1;
 		}
 	}
@@ -296,6 +297,7 @@
 	} else {
 		i_assert(cache->hdr != NULL);
 	}
+	i_assert(cache->hdr->file_seq != 0);
 
 	if (offset + size > cache->mmap_length)
 		return 0;
@@ -365,8 +367,6 @@
 		return mail_cache_map_with_read(cache, offset, size, data_r);
 
 	if (cache->file_cache != NULL) {
-		cache->hdr = NULL;
-
 		ret = file_cache_read(cache->file_cache, offset, size);
 		if (ret < 0) {
                         /* In case of ESTALE we'll simply fail without error
@@ -378,6 +378,7 @@
                            offsets. */
                         if (errno != ESTALE)
                                 mail_cache_set_syscall_error(cache, "read()");
+			cache->hdr = NULL;
 			return -1;
 		}
 
@@ -385,7 +386,8 @@
 					  &cache->mmap_length);
 		*data_r = offset > cache->mmap_length ? NULL :
 			CONST_PTR_OFFSET(data, offset);
-		return mail_cache_map_finish(cache, offset, size, data, TRUE);
+		return mail_cache_map_finish(cache, offset, size,
+					     offset == 0 ? data : NULL, TRUE);
 	}
 
 	if (offset < cache->mmap_length &&


More information about the dovecot-cvs mailing list