changeset 9454:87e533f1127d HEAD

mailbox_header_lookup*() private API changed.
author Timo Sirainen <tss@iki.fi>
date Thu, 04 Jun 2009 19:30:46 -0400
parents 2a3390530f6a
children 374d29a1905e
files src/lib-storage/index/cydir/cydir-storage.c src/lib-storage/index/dbox/dbox-storage.c src/lib-storage/index/index-mail-headers.c src/lib-storage/index/index-storage.h src/lib-storage/index/maildir/maildir-storage.c src/lib-storage/index/mbox/mbox-storage.c src/lib-storage/index/raw/raw-storage.c src/lib-storage/mail-storage-private.h src/lib-storage/mail-storage.c src/plugins/virtual/virtual-storage.c
diffstat 10 files changed, 19 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/cydir/cydir-storage.c	Thu Jun 04 18:58:38 2009 -0400
+++ b/src/lib-storage/index/cydir/cydir-storage.c	Thu Jun 04 19:30:46 2009 -0400
@@ -395,8 +395,7 @@
 		NULL,
 		index_mail_alloc,
 		index_header_lookup_init,
-		index_header_lookup_ref,
-		index_header_lookup_unref,
+		index_header_lookup_deinit,
 		index_storage_search_init,
 		index_storage_search_deinit,
 		index_storage_search_next_nonblock,
--- a/src/lib-storage/index/dbox/dbox-storage.c	Thu Jun 04 18:58:38 2009 -0400
+++ b/src/lib-storage/index/dbox/dbox-storage.c	Thu Jun 04 19:30:46 2009 -0400
@@ -796,8 +796,7 @@
 		NULL,
 		dbox_mail_alloc,
 		index_header_lookup_init,
-		index_header_lookup_ref,
-		index_header_lookup_unref,
+		index_header_lookup_deinit,
 		index_storage_search_init,
 		index_storage_search_deinit,
 		index_storage_search_next_nonblock,
--- a/src/lib-storage/index/index-mail-headers.c	Thu Jun 04 18:58:38 2009 -0400
+++ b/src/lib-storage/index/index-mail-headers.c	Thu Jun 04 19:30:46 2009 -0400
@@ -885,6 +885,7 @@
 	pool = pool_alloconly_create("index_header_lookup_ctx", 1024);
 	ctx = p_new(pool, struct index_header_lookup_ctx, 1);
 	ctx->ctx.box = box;
+	ctx->ctx.refcount = 1;
 	ctx->pool = pool;
 	ctx->count = count;
 
@@ -911,15 +912,7 @@
 	return ctx;
 }
 
-void index_header_lookup_ref(struct mailbox_header_lookup_ctx *_ctx)
-{
-	struct index_header_lookup_ctx *ctx =
-		(struct index_header_lookup_ctx *)_ctx;
-
-	pool_ref(ctx->pool);
-}
-
-void index_header_lookup_unref(struct mailbox_header_lookup_ctx *_ctx)
+void index_header_lookup_deinit(struct mailbox_header_lookup_ctx *_ctx)
 {
 	struct index_header_lookup_ctx *ctx =
 		(struct index_header_lookup_ctx *)_ctx;
--- a/src/lib-storage/index/index-storage.h	Thu Jun 04 18:58:38 2009 -0400
+++ b/src/lib-storage/index/index-storage.h	Thu Jun 04 19:30:46 2009 -0400
@@ -150,8 +150,7 @@
 
 struct mailbox_header_lookup_ctx *
 index_header_lookup_init(struct mailbox *box, const char *const headers[]);
-void index_header_lookup_ref(struct mailbox_header_lookup_ctx *ctx);
-void index_header_lookup_unref(struct mailbox_header_lookup_ctx *ctx);
+void index_header_lookup_deinit(struct mailbox_header_lookup_ctx *ctx);
 
 struct mail_search_context *
 index_storage_search_init(struct mailbox_transaction_context *t,
--- a/src/lib-storage/index/maildir/maildir-storage.c	Thu Jun 04 18:58:38 2009 -0400
+++ b/src/lib-storage/index/maildir/maildir-storage.c	Thu Jun 04 19:30:46 2009 -0400
@@ -1079,8 +1079,7 @@
 		NULL,
 		index_mail_alloc,
 		index_header_lookup_init,
-		index_header_lookup_ref,
-		index_header_lookup_unref,
+		index_header_lookup_deinit,
 		index_storage_search_init,
 		index_storage_search_deinit,
 		index_storage_search_next_nonblock,
--- a/src/lib-storage/index/mbox/mbox-storage.c	Thu Jun 04 18:58:38 2009 -0400
+++ b/src/lib-storage/index/mbox/mbox-storage.c	Thu Jun 04 19:30:46 2009 -0400
@@ -912,8 +912,7 @@
 		NULL,
 		index_mail_alloc,
 		index_header_lookup_init,
-		index_header_lookup_ref,
-		index_header_lookup_unref,
+		index_header_lookup_deinit,
 		index_storage_search_init,
 		index_storage_search_deinit,
 		index_storage_search_next_nonblock,
--- a/src/lib-storage/index/raw/raw-storage.c	Thu Jun 04 18:58:38 2009 -0400
+++ b/src/lib-storage/index/raw/raw-storage.c	Thu Jun 04 19:30:46 2009 -0400
@@ -246,8 +246,7 @@
 		NULL,
 		index_mail_alloc,
 		index_header_lookup_init,
-		index_header_lookup_ref,
-		index_header_lookup_unref,
+		index_header_lookup_deinit,
 		index_storage_search_init,
 		index_storage_search_deinit,
 		index_storage_search_next_nonblock,
--- a/src/lib-storage/mail-storage-private.h	Thu Jun 04 18:58:38 2009 -0400
+++ b/src/lib-storage/mail-storage-private.h	Thu Jun 04 19:30:46 2009 -0400
@@ -180,8 +180,7 @@
 	struct mailbox_header_lookup_ctx *
 		(*header_lookup_init)(struct mailbox *box,
 				      const char *const headers[]);
-	void (*header_lookup_ref)(struct mailbox_header_lookup_ctx *ctx);
-	void (*header_lookup_unref)(struct mailbox_header_lookup_ctx *ctx);
+	void (*header_lookup_deinit)(struct mailbox_header_lookup_ctx *ctx);
 
 	struct mail_search_context *
 	(*search_init)(struct mailbox_transaction_context *t,
@@ -390,6 +389,7 @@
 struct mailbox_header_lookup_ctx {
 	struct mailbox *box;
 	const char *const *headers;
+	int refcount;
 };
 
 /* Modules should use do "my_id = mail_storage_module_id++" and
--- a/src/lib-storage/mail-storage.c	Thu Jun 04 18:58:38 2009 -0400
+++ b/src/lib-storage/mail-storage.c	Thu Jun 04 19:30:46 2009 -0400
@@ -721,7 +721,8 @@
 
 void mailbox_header_lookup_ref(struct mailbox_header_lookup_ctx *ctx)
 {
-	ctx->box->v.header_lookup_ref(ctx);
+	i_assert(ctx->refcount > 0);
+	ctx->refcount++;
 }
 
 void mailbox_header_lookup_unref(struct mailbox_header_lookup_ctx **_ctx)
@@ -729,7 +730,12 @@
 	struct mailbox_header_lookup_ctx *ctx = *_ctx;
 
 	*_ctx = NULL;
-	ctx->box->v.header_lookup_unref(ctx);
+
+	i_assert(ctx->refcount > 0);
+	if (--ctx->refcount > 0)
+		return;
+
+	ctx->box->v.header_lookup_deinit(ctx);
 }
 
 struct mail_search_context *
--- a/src/plugins/virtual/virtual-storage.c	Thu Jun 04 18:58:38 2009 -0400
+++ b/src/plugins/virtual/virtual-storage.c	Thu Jun 04 19:30:46 2009 -0400
@@ -617,8 +617,7 @@
 		virtual_get_virtual_box_patterns,
 		virtual_mail_alloc,
 		index_header_lookup_init,
-		index_header_lookup_ref,
-		index_header_lookup_unref,
+		index_header_lookup_deinit,
 		virtual_search_init,
 		virtual_search_deinit,
 		virtual_search_next_nonblock,