dovecot: mail_cache_lookup_iter_next() returned -1 if entry didn...

dovecot at dovecot.org dovecot at dovecot.org
Sun Jul 15 02:43:41 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/7c1e6ea4bfab
changeset: 6005:7c1e6ea4bfab
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Jul 15 02:43:34 2007 +0300
description:
mail_cache_lookup_iter_next() returned -1 if entry didn't exist, causing
the first field for the record not to be added to cache.

diffstat:

2 files changed, 10 insertions(+), 5 deletions(-)
src/lib-index/mail-cache-lookup.c  |   14 +++++++++-----
src/lib-index/mail-cache-private.h |    1 +

diffs (49 lines):

diff -r 6645e902b8a0 -r 7c1e6ea4bfab src/lib-index/mail-cache-lookup.c
--- a/src/lib-index/mail-cache-lookup.c	Sun Jul 15 02:31:20 2007 +0300
+++ b/src/lib-index/mail-cache-lookup.c	Sun Jul 15 02:43:34 2007 +0300
@@ -111,6 +111,7 @@ void mail_cache_lookup_iter_init(struct 
 				 struct mail_cache_lookup_iterate_ctx *ctx_r)
 {
 	struct mail_cache_lookup_iterate_ctx *ctx = ctx_r;
+	int ret;
 
 	if (!view->cache->opened)
 		(void)mail_cache_open_and_verify(view->cache);
@@ -121,9 +122,12 @@ void mail_cache_lookup_iter_init(struct 
 
 	if (!MAIL_CACHE_IS_UNUSABLE(view->cache)) {
 		/* look up the first offset */
-		if (mail_cache_lookup_offset(view->cache, view->view, seq,
-					     &ctx->offset) <= 0)
-			ctx->failed = TRUE;
+		ret = mail_cache_lookup_offset(view->cache, view->view, seq,
+					       &ctx->offset);
+		if (ret <= 0) {
+			ctx->stop = TRUE;
+			ctx->failed = ret < 0;
+		}
 	}
 	ctx->remap_counter = view->cache->remap_counter;
 
@@ -135,8 +139,8 @@ mail_cache_lookup_iter_next_record(struc
 {
 	struct mail_cache_view *view = ctx->view;
 
-	if (ctx->failed)
-		return -1;
+	if (ctx->stop)
+		return ctx->failed ? -1 : 0;
 
 	if (ctx->rec != NULL)
 		ctx->offset = ctx->rec->prev_offset;
diff -r 6645e902b8a0 -r 7c1e6ea4bfab src/lib-index/mail-cache-private.h
--- a/src/lib-index/mail-cache-private.h	Sun Jul 15 02:31:20 2007 +0300
+++ b/src/lib-index/mail-cache-private.h	Sun Jul 15 02:43:34 2007 +0300
@@ -188,6 +188,7 @@ struct mail_cache_lookup_iterate_ctx {
 	unsigned int pos, rec_size;
 	uint32_t offset;
 
+	unsigned int stop:1;
 	unsigned int failed:1;
 	unsigned int appends_checked:1;
 };


More information about the dovecot-cvs mailing list