dovecot-1.3: mail_search_args_[de]init() calls stack now. Last u...

dovecot at dovecot.org dovecot at dovecot.org
Thu Apr 16 03:25:06 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.3/rev/8b831d260dca
changeset: 9114:8b831d260dca
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Apr 15 20:24:37 2009 -0400
description:
mail_search_args_[de]init() calls stack now. Last unref is still allowed without deiniting.

diffstat:

2 files changed, 10 insertions(+), 8 deletions(-)
src/lib-storage/mail-search.c |   14 ++++++++------
src/lib-storage/mail-search.h |    4 ++--

diffs (61 lines):

diff -r 093c15fed377 -r 8b831d260dca src/lib-storage/mail-search.c
--- a/src/lib-storage/mail-search.c	Wed Apr 15 19:48:55 2009 -0400
+++ b/src/lib-storage/mail-search.c	Wed Apr 15 20:24:37 2009 -0400
@@ -122,7 +122,7 @@ void mail_search_args_init(struct mail_s
 			   struct mailbox *box, bool change_uidsets,
 			   const ARRAY_TYPE(seq_range) *search_saved_uidset)
 {
-	if (args->initialized) {
+	if (args->init_refcount++ > 0) {
 		i_assert(args->box == box);
 		return;
 	}
@@ -167,11 +167,10 @@ static void mail_search_args_deinit_sub(
 
 void mail_search_args_deinit(struct mail_search_args *args)
 {
-	if (args->refcount > 1 || !args->initialized)
+	if (--args->init_refcount > 0)
 		return;
 
 	mail_search_args_deinit_sub(args, args->args);
-	args->initialized = FALSE;
 	args->box = NULL;
 }
 
@@ -229,10 +228,13 @@ void mail_search_args_unref(struct mail_
 	i_assert(args->refcount > 0);
 
 	*_args = NULL;
-	if (--args->refcount > 0)
+	if (--args->refcount > 0) {
+		i_assert(args->init_refcount <= args->refcount);
 		return;
-
-	mail_search_args_deinit(args);
+	}
+	i_assert(args->init_refcount <= 1);
+	if (args->init_refcount == 1)
+		mail_search_args_deinit(args);
 	pool_unref(&args->pool);
 }
 
diff -r 093c15fed377 -r 8b831d260dca src/lib-storage/mail-search.h
--- a/src/lib-storage/mail-search.h	Wed Apr 15 19:48:55 2009 -0400
+++ b/src/lib-storage/mail-search.h	Wed Apr 15 20:24:37 2009 -0400
@@ -93,13 +93,13 @@ struct mail_search_arg {
 };
 
 struct mail_search_args {
-	int refcount;
+	int refcount, init_refcount;
+
 	pool_t pool;
 	struct mailbox *box;
 	struct mail_search_arg *args;
 	const char *charset;
 
-	unsigned int initialized:1;
 	unsigned int simplified:1;
 	unsigned int have_inthreads:1;
 };


More information about the dovecot-cvs mailing list