changeset 7827:6659785091ab HEAD

thread indexes: Fixed infinite loop.
author Timo Sirainen <tss@iki.fi>
date Thu, 12 Jun 2008 01:42:21 +0300
parents b63aa0ffe564
children 7caab06fb890
files src/lib-storage/index/index-thread.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/index-thread.c	Thu Jun 12 00:31:59 2008 +0300
+++ b/src/lib-storage/index/index-thread.c	Thu Jun 12 01:42:21 2008 +0300
@@ -181,6 +181,7 @@
 			 const struct mailbox_status *status, bool reset,
 			 struct mail_search_args *search_args)
 {
+	struct mail_search_arg *limit_arg = NULL;
 	const struct mail_hash_header *hdr;
 	struct mail_hash_transaction *hash_trans;
 	uint32_t last_seq, last_uid, seq1, seq2;
@@ -276,8 +277,7 @@
 				seq_range_array_add_range(&arg->value.seqset,
 							  seq2 + 1, last_seq);
 			}
-			ctx->tmp_search_arg.next = search_args->args;
-			search_args->args = &ctx->tmp_search_arg;
+			limit_arg = &ctx->tmp_search_arg;
 		}
 	} else {
 		/* empty hash - make sure anyway that it gets reset */
@@ -291,6 +291,7 @@
 				MAIL_HASH_LOCK_FLAG_CREATE_MISSING) <= 0)
 			return FALSE;
 		shared_lock = TRUE;
+		limit_arg = NULL;
 		goto again;
 	}
 	if (!can_use) {
@@ -299,6 +300,10 @@
 		return FALSE;
 	} else {
 		ctx->thread_ctx.hash_trans = hash_trans;
+		if (limit_arg != NULL) {
+			limit_arg->next = search_args->args;
+			search_args->args = limit_arg;
+		}
 		return TRUE;
 	}
 }