can be shared among multiple struct mails.
--HG--
branch : HEAD
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);
if (mail == NULL) {
/* deinit */
- mailbox_header_lookup_deinit(&body->header_ctx);
+ mailbox_header_lookup_unref(&body->header_ctx);
return 0;
}
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
}
if (headers_ctx != NULL)
- mailbox_header_lookup_deinit(&headers_ctx);
+ mailbox_header_lookup_unref(&headers_ctx);
return ret;
}
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,
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,
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;
}
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);
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;
}
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;
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)
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);
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);
}
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;
}
}
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;
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,
} 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;
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,
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,
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,
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,
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 *
/* 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
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,