dovecot-1.2: struct mailbox_header_lookup_ctx can now be referen...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Jul 19 14:43:30 EEST 2008
details: http://hg.dovecot.org/dovecot-1.2/rev/2d902d1f8bea
changeset: 8011:2d902d1f8bea
user: Timo Sirainen <tss at iki.fi>
date: Sat Jul 19 14:43:24 2008 +0300
description:
struct mailbox_header_lookup_ctx can now be referenced/unreferenced so it
can be shared among multiple struct mails.
diffstat:
18 files changed, 52 insertions(+), 23 deletions(-)
src/deliver/deliver.c | 2 +-
src/imap/imap-fetch-body.c | 2 +-
src/imap/imap-fetch.c | 2 +-
src/imap/imap-sort.c | 2 +-
src/lib-storage/index/cydir/cydir-storage.c | 3 ++-
src/lib-storage/index/dbox/dbox-storage.c | 3 ++-
src/lib-storage/index/index-mail-headers.c | 16 ++++++++++++----
src/lib-storage/index/index-mail.c | 9 ++++++++-
src/lib-storage/index/index-search.c | 4 ++--
src/lib-storage/index/index-storage.h | 3 ++-
src/lib-storage/index/index-thread.c | 2 +-
src/lib-storage/index/maildir/maildir-storage.c | 3 ++-
src/lib-storage/index/mbox/mbox-storage.c | 3 ++-
src/lib-storage/index/raw/raw-storage.c | 3 ++-
src/lib-storage/mail-storage-private.h | 3 ++-
src/lib-storage/mail-storage.c | 9 +++++++--
src/lib-storage/mail-storage.h | 3 ++-
src/plugins/virtual/virtual-storage.c | 3 ++-
diffs (truncated from 303 to 300 lines):
diff -r 2c1e4f1fc4e0 -r 2d902d1f8bea src/deliver/deliver.c
--- a/src/deliver/deliver.c Fri Jul 18 17:55:02 2008 +0300
+++ b/src/deliver/deliver.c Sat Jul 19 14:43:24 2008 +0300
@@ -1088,7 +1088,7 @@ int main(int argc, char *argv[])
i_free(explicit_envelope_sender);
mail_free(&mail);
- mailbox_header_lookup_deinit(&headers_ctx);
+ mailbox_header_lookup_unref(&headers_ctx);
mailbox_transaction_rollback(&t);
mailbox_close(&box);
diff -r 2c1e4f1fc4e0 -r 2d902d1f8bea src/imap/imap-fetch-body.c
--- a/src/imap/imap-fetch-body.c Fri Jul 18 17:55:02 2008 +0300
+++ b/src/imap/imap-fetch-body.c Sat Jul 19 14:43:24 2008 +0300
@@ -444,7 +444,7 @@ fetch_body_header_fields(struct imap_fet
if (mail == NULL) {
/* deinit */
- mailbox_header_lookup_deinit(&body->header_ctx);
+ mailbox_header_lookup_unref(&body->header_ctx);
return 0;
}
diff -r 2c1e4f1fc4e0 -r 2d902d1f8bea src/imap/imap-fetch.c
--- a/src/imap/imap-fetch.c Fri Jul 18 17:55:02 2008 +0300
+++ b/src/imap/imap-fetch.c Sat Jul 19 14:43:24 2008 +0300
@@ -568,7 +568,7 @@ int imap_fetch_deinit(struct imap_fetch_
ctx->failed = TRUE;
}
if (ctx->all_headers_ctx != NULL)
- mailbox_header_lookup_deinit(&ctx->all_headers_ctx);
+ mailbox_header_lookup_unref(&ctx->all_headers_ctx);
if (ctx->trans != NULL) {
/* even if something failed, we want to commit changes to
diff -r 2c1e4f1fc4e0 -r 2d902d1f8bea src/imap/imap-sort.c
--- a/src/imap/imap-sort.c Fri Jul 18 17:55:02 2008 +0300
+++ b/src/imap/imap-sort.c Sat Jul 19 14:43:24 2008 +0300
@@ -108,6 +108,6 @@ int imap_sort(struct client_command_cont
}
if (headers_ctx != NULL)
- mailbox_header_lookup_deinit(&headers_ctx);
+ mailbox_header_lookup_unref(&headers_ctx);
return ret;
}
diff -r 2c1e4f1fc4e0 -r 2d902d1f8bea src/lib-storage/index/cydir/cydir-storage.c
--- a/src/lib-storage/index/cydir/cydir-storage.c Fri Jul 18 17:55:02 2008 +0300
+++ b/src/lib-storage/index/cydir/cydir-storage.c Sat Jul 19 14:43:24 2008 +0300
@@ -441,7 +441,8 @@ struct mailbox cydir_mailbox = {
index_storage_get_expunged_uids,
index_mail_alloc,
index_header_lookup_init,
- index_header_lookup_deinit,
+ index_header_lookup_ref,
+ index_header_lookup_unref,
index_storage_search_init,
index_storage_search_deinit,
index_storage_search_next_nonblock,
diff -r 2c1e4f1fc4e0 -r 2d902d1f8bea src/lib-storage/index/dbox/dbox-storage.c
--- a/src/lib-storage/index/dbox/dbox-storage.c Fri Jul 18 17:55:02 2008 +0300
+++ b/src/lib-storage/index/dbox/dbox-storage.c Sat Jul 19 14:43:24 2008 +0300
@@ -701,7 +701,8 @@ struct mailbox dbox_mailbox = {
index_storage_get_expunged_uids,
dbox_mail_alloc,
index_header_lookup_init,
- index_header_lookup_deinit,
+ index_header_lookup_ref,
+ index_header_lookup_unref,
index_storage_search_init,
index_storage_search_deinit,
index_storage_search_next_nonblock,
diff -r 2c1e4f1fc4e0 -r 2d902d1f8bea src/lib-storage/index/index-mail-headers.c
--- a/src/lib-storage/index/index-mail-headers.c Fri Jul 18 17:55:02 2008 +0300
+++ b/src/lib-storage/index/index-mail-headers.c Sat Jul 19 14:43:24 2008 +0300
@@ -458,7 +458,7 @@ int index_mail_headers_get_envelope(stru
header_ctx = mailbox_header_lookup_init(&mail->ibox->box,
imap_envelope_headers);
if (mail_get_header_stream(&mail->mail.mail, header_ctx, &stream) < 0) {
- mailbox_header_lookup_deinit(&header_ctx);
+ mailbox_header_lookup_unref(&header_ctx);
return -1;
}
@@ -469,7 +469,7 @@ int index_mail_headers_get_envelope(stru
imap_envelope_parse_callback, mail);
mail->data.save_envelope = FALSE;
}
- mailbox_header_lookup_deinit(&header_ctx);
+ mailbox_header_lookup_unref(&header_ctx);
if (mail->data.stream != NULL)
i_stream_seek(mail->data.stream, old_offset);
@@ -595,7 +595,7 @@ index_mail_get_raw_headers(struct index_
headers_ctx = mailbox_header_lookup_init(
&mail->ibox->box, headers);
ret = index_mail_parse_headers(mail, headers_ctx);
- mailbox_header_lookup_deinit(&headers_ctx);
+ mailbox_header_lookup_unref(&headers_ctx);
if (ret < 0)
return -1;
}
@@ -818,10 +818,18 @@ index_header_lookup_init(struct mailbox
return ctx;
}
-void index_header_lookup_deinit(struct mailbox_header_lookup_ctx *_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)
+{
+ struct index_header_lookup_ctx *ctx =
+ (struct index_header_lookup_ctx *)_ctx;
+
pool_unref(&ctx->pool);
}
diff -r 2c1e4f1fc4e0 -r 2d902d1f8bea src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c Fri Jul 18 17:55:02 2008 +0300
+++ b/src/lib-storage/index/index-mail.c Sat Jul 19 14:43:24 2008 +0300
@@ -1071,7 +1071,10 @@ void index_mail_init(struct index_mail *
mail->ibox = t->ibox;
mail->trans = t;
mail->wanted_fields = wanted_fields;
- mail->wanted_headers = wanted_headers;
+ if (wanted_headers != NULL) {
+ mail->wanted_headers = wanted_headers;
+ mailbox_header_lookup_ref(_wanted_headers);
+ }
}
void index_mail_close(struct mail *_mail)
@@ -1282,6 +1285,8 @@ void index_mail_free(struct mail *_mail)
void index_mail_free(struct mail *_mail)
{
struct index_mail *mail = (struct index_mail *)_mail;
+ struct mailbox_header_lookup_ctx *headers_ctx =
+ (struct mailbox_header_lookup_ctx *)mail->wanted_headers;
mail->mail.v.close(_mail);
@@ -1297,6 +1302,8 @@ void index_mail_free(struct mail *_mail)
if (array_is_created(&mail->header_match_lines))
array_free(&mail->header_match_lines);
+ if (headers_ctx != NULL)
+ mailbox_header_lookup_unref(&headers_ctx);
pool_unref(&mail->data_pool);
pool_unref(&mail->mail.pool);
}
diff -r 2c1e4f1fc4e0 -r 2d902d1f8bea src/lib-storage/index/index-search.c
--- a/src/lib-storage/index/index-search.c Fri Jul 18 17:55:02 2008 +0300
+++ b/src/lib-storage/index/index-search.c Sat Jul 19 14:43:24 2008 +0300
@@ -586,7 +586,7 @@ static bool search_arg_match_text(struct
headers);
if (mail_get_header_stream(ctx->mail, headers_ctx,
&input) < 0) {
- mailbox_header_lookup_deinit(&headers_ctx);
+ mailbox_header_lookup_unref(&headers_ctx);
return FALSE;
}
}
@@ -603,7 +603,7 @@ static bool search_arg_match_text(struct
message_parse_header(input, NULL, hdr_parser_flags,
search_header, &hdr_ctx);
if (headers_ctx != NULL)
- mailbox_header_lookup_deinit(&headers_ctx);
+ mailbox_header_lookup_unref(&headers_ctx);
} else {
struct message_size hdr_size;
diff -r 2c1e4f1fc4e0 -r 2d902d1f8bea src/lib-storage/index/index-storage.h
--- a/src/lib-storage/index/index-storage.h Fri Jul 18 17:55:02 2008 +0300
+++ b/src/lib-storage/index/index-storage.h Sat Jul 19 14:43:24 2008 +0300
@@ -157,7 +157,8 @@ bool index_storage_get_expunged_uids(str
struct mailbox_header_lookup_ctx *
index_header_lookup_init(struct mailbox *box, const char *const headers[]);
-void index_header_lookup_deinit(struct mailbox_header_lookup_ctx *ctx);
+void index_header_lookup_ref(struct mailbox_header_lookup_ctx *ctx);
+void index_header_lookup_unref(struct mailbox_header_lookup_ctx *ctx);
struct mail_search_context *
index_storage_search_init(struct mailbox_transaction_context *t,
diff -r 2c1e4f1fc4e0 -r 2d902d1f8bea src/lib-storage/index/index-thread.c
--- a/src/lib-storage/index/index-thread.c Fri Jul 18 17:55:02 2008 +0300
+++ b/src/lib-storage/index/index-thread.c Sat Jul 19 14:43:24 2008 +0300
@@ -433,7 +433,7 @@ mail_thread_update(struct mail_thread_co
} T_END;
}
mail_free(&mail);
- mailbox_header_lookup_deinit(&headers_ctx);
+ mailbox_header_lookup_unref(&headers_ctx);
if (ret < 0 || ctx->thread_ctx.failed || ctx->thread_ctx.rebuild)
return -1;
diff -r 2c1e4f1fc4e0 -r 2d902d1f8bea src/lib-storage/index/maildir/maildir-storage.c
--- a/src/lib-storage/index/maildir/maildir-storage.c Fri Jul 18 17:55:02 2008 +0300
+++ b/src/lib-storage/index/maildir/maildir-storage.c Sat Jul 19 14:43:24 2008 +0300
@@ -1046,7 +1046,8 @@ struct mailbox maildir_mailbox = {
index_storage_get_expunged_uids,
index_mail_alloc,
index_header_lookup_init,
- index_header_lookup_deinit,
+ index_header_lookup_ref,
+ index_header_lookup_unref,
index_storage_search_init,
index_storage_search_deinit,
index_storage_search_next_nonblock,
diff -r 2c1e4f1fc4e0 -r 2d902d1f8bea src/lib-storage/index/mbox/mbox-storage.c
--- a/src/lib-storage/index/mbox/mbox-storage.c Fri Jul 18 17:55:02 2008 +0300
+++ b/src/lib-storage/index/mbox/mbox-storage.c Sat Jul 19 14:43:24 2008 +0300
@@ -1002,7 +1002,8 @@ struct mailbox mbox_mailbox = {
index_storage_get_expunged_uids,
index_mail_alloc,
index_header_lookup_init,
- index_header_lookup_deinit,
+ index_header_lookup_ref,
+ index_header_lookup_unref,
index_storage_search_init,
index_storage_search_deinit,
index_storage_search_next_nonblock,
diff -r 2c1e4f1fc4e0 -r 2d902d1f8bea src/lib-storage/index/raw/raw-storage.c
--- a/src/lib-storage/index/raw/raw-storage.c Fri Jul 18 17:55:02 2008 +0300
+++ b/src/lib-storage/index/raw/raw-storage.c Sat Jul 19 14:43:24 2008 +0300
@@ -297,7 +297,8 @@ struct mailbox raw_mailbox = {
index_storage_get_expunged_uids,
index_mail_alloc,
index_header_lookup_init,
- index_header_lookup_deinit,
+ index_header_lookup_ref,
+ index_header_lookup_unref,
index_storage_search_init,
index_storage_search_deinit,
index_storage_search_next_nonblock,
diff -r 2c1e4f1fc4e0 -r 2d902d1f8bea src/lib-storage/mail-storage-private.h
--- a/src/lib-storage/mail-storage-private.h Fri Jul 18 17:55:02 2008 +0300
+++ b/src/lib-storage/mail-storage-private.h Sat Jul 19 14:43:24 2008 +0300
@@ -145,7 +145,8 @@ struct mailbox_vfuncs {
struct mailbox_header_lookup_ctx *
(*header_lookup_init)(struct mailbox *box,
const char *const headers[]);
- void (*header_lookup_deinit)(struct mailbox_header_lookup_ctx *ctx);
+ void (*header_lookup_ref)(struct mailbox_header_lookup_ctx *ctx);
+ void (*header_lookup_unref)(struct mailbox_header_lookup_ctx *ctx);
struct mail_search_context *
(*search_init)(struct mailbox_transaction_context *t,
diff -r 2c1e4f1fc4e0 -r 2d902d1f8bea src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c Fri Jul 18 17:55:02 2008 +0300
+++ b/src/lib-storage/mail-storage.c Sat Jul 19 14:43:24 2008 +0300
@@ -629,12 +629,17 @@ mailbox_header_lookup_init(struct mailbo
return box->v.header_lookup_init(box, headers);
}
-void mailbox_header_lookup_deinit(struct mailbox_header_lookup_ctx **_ctx)
+void mailbox_header_lookup_ref(struct mailbox_header_lookup_ctx *ctx)
+{
+ ctx->box->v.header_lookup_ref(ctx);
+}
+
+void mailbox_header_lookup_unref(struct mailbox_header_lookup_ctx **_ctx)
{
struct mailbox_header_lookup_ctx *ctx = *_ctx;
*_ctx = NULL;
- ctx->box->v.header_lookup_deinit(ctx);
+ ctx->box->v.header_lookup_unref(ctx);
}
struct mail_search_context *
diff -r 2c1e4f1fc4e0 -r 2d902d1f8bea src/lib-storage/mail-storage.h
--- a/src/lib-storage/mail-storage.h Fri Jul 18 17:55:02 2008 +0300
+++ b/src/lib-storage/mail-storage.h Sat Jul 19 14:43:24 2008 +0300
@@ -404,7 +404,8 @@ bool mailbox_get_expunged_uids(struct ma
/* Initialize header lookup for given headers. */
struct mailbox_header_lookup_ctx *
mailbox_header_lookup_init(struct mailbox *box, const char *const headers[]);
-void mailbox_header_lookup_deinit(struct mailbox_header_lookup_ctx **ctx);
+void mailbox_header_lookup_ref(struct mailbox_header_lookup_ctx *ctx);
+void mailbox_header_lookup_unref(struct mailbox_header_lookup_ctx **ctx);
/* Initialize new search request. charset specifies the character set used in
the search argument strings. If sort_program is non-NULL, the messages are
diff -r 2c1e4f1fc4e0 -r 2d902d1f8bea src/plugins/virtual/virtual-storage.c
--- a/src/plugins/virtual/virtual-storage.c Fri Jul 18 17:55:02 2008 +0300
+++ b/src/plugins/virtual/virtual-storage.c Sat Jul 19 14:43:24 2008 +0300
@@ -530,7 +530,8 @@ struct mailbox virtual_mailbox = {
index_storage_get_expunged_uids,
virtual_mail_alloc,
index_header_lookup_init,
- index_header_lookup_deinit,
+ index_header_lookup_ref,
+ index_header_lookup_unref,
More information about the dovecot-cvs
mailing list