Mercurial > dovecot > original-hg > dovecot-1.2
changeset 8011:2d902d1f8bea HEAD
struct mailbox_header_lookup_ctx can now be referenced/unreferenced so it
can be shared among multiple struct mails.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 19 Jul 2008 14:43:24 +0300 |
parents | 2c1e4f1fc4e0 |
children | 164bdad216b8 |
files | src/deliver/deliver.c src/imap/imap-fetch-body.c src/imap/imap-fetch.c src/imap/imap-sort.c 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-mail.c src/lib-storage/index/index-search.c src/lib-storage/index/index-storage.h src/lib-storage/index/index-thread.c 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/lib-storage/mail-storage.h src/plugins/virtual/virtual-storage.c |
diffstat | 18 files changed, 52 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ 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);
--- 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 @@ if (mail == NULL) { /* deinit */ - mailbox_header_lookup_deinit(&body->header_ctx); + mailbox_header_lookup_unref(&body->header_ctx); return 0; }
--- 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 @@ 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
--- 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 @@ } if (headers_ctx != NULL) - mailbox_header_lookup_deinit(&headers_ctx); + mailbox_header_lookup_unref(&headers_ctx); return ret; }
--- 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 @@ 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,
--- 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 @@ 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,
--- 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 @@ 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 @@ 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 @@ 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,7 +818,15 @@ 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;
--- 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 @@ 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) { 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 @@ 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); }
--- 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 @@ 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 @@ 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;
--- 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 @@ 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,
--- 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 @@ } 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;
--- 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 @@ 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,
--- 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 @@ 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,
--- 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 @@ 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,
--- 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_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,
--- 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 @@ 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 *
--- 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 @@ /* 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
--- 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 @@ index_storage_get_expunged_uids, virtual_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,