]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
struct mailbox_header_lookup_ctx can now be referenced/unreferenced so it
authorTimo Sirainen <tss@iki.fi>
Sat, 19 Jul 2008 11:43:24 +0000 (14:43 +0300)
committerTimo Sirainen <tss@iki.fi>
Sat, 19 Jul 2008 11:43:24 +0000 (14:43 +0300)
can be shared among multiple struct mails.

--HG--
branch : HEAD

18 files changed:
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

index 0773e419aa436dfc58fa5a8bc4e193a929c5ccbf..696979e7133f1b0bd437152d0f2e07b9729a1b74 100644 (file)
@@ -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);
 
index 9a102a02ccb1822e5f241fc76810a517b8e186e3..5382613872ced97bf0543abd95c3dc8cc534c1d5 100644 (file)
@@ -444,7 +444,7 @@ fetch_body_header_fields(struct imap_fetch_context *ctx, struct mail *mail,
 
        if (mail == NULL) {
                /* deinit */
-               mailbox_header_lookup_deinit(&body->header_ctx);
+               mailbox_header_lookup_unref(&body->header_ctx);
                return 0;
        }
 
index 185ef5705e67f24fef44c7cdbd333ebce27ff5c0..1efb0a671357a5ebf575119eb354f58d07eec340 100644 (file)
@@ -568,7 +568,7 @@ int imap_fetch_deinit(struct imap_fetch_context *ctx)
                        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
index 8994ab324656809bd397526f8d389471aeb4416b..45b0c39a68ce20dbf4838bca8c227efa7572a8a3 100644 (file)
@@ -108,6 +108,6 @@ int imap_sort(struct client_command_context *cmd, struct mail_search_args *args,
        }
 
        if (headers_ctx != NULL)
-               mailbox_header_lookup_deinit(&headers_ctx);
+               mailbox_header_lookup_unref(&headers_ctx);
        return ret;
 }
index df4b6283e2068183af5a03df2c8fd09d3d579db6..27b4c87004d50fec6220f6134c6f135e983293c6 100644 (file)
@@ -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,
index 6ba864fe5bc6f24b5235192d1aee1dc6e92d1da8..c089ff818ce3d932751c50841fc200c7cb451398 100644 (file)
@@ -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,
index 640bfe82c62ef73d23f57f7db665bd658ec1737b..81e17543bea22cfa2d33ebf6a16b0fe75ac7e64a 100644 (file)
@@ -458,7 +458,7 @@ int index_mail_headers_get_envelope(struct index_mail *mail)
        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(struct index_mail *mail)
                                     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_mail *mail, const char *field,
                        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 @@ index_header_lookup_init(struct mailbox *box, const char *const headers[])
        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;
index 8bd906e73fc765d2dfc3bdb30fa7d2246230ec04..2423eccbf4be23893c990a89b6a51ab91e89aa74 100644 (file)
@@ -1071,7 +1071,10 @@ void index_mail_init(struct index_mail *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 @@ bool index_mail_set_uid(struct mail *_mail, uint32_t uid)
 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);
 }
index 02785a67110c0f6696ca694108a7e6495ea7dfae..8be12d07a47f23e1c9ab62b44caa1398eb896541 100644 (file)
@@ -586,7 +586,7 @@ static bool search_arg_match_text(struct mail_search_arg *args,
                                                           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 mail_search_arg *args,
                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;
 
index 8f9ff364a00ce72ac1170bddb918cefa9368672f..60f0404032f7288cf42cf4a5f09819cf2af83fc4 100644 (file)
@@ -157,7 +157,8 @@ bool index_storage_get_expunged_uids(struct mailbox *box, uint64_t modseq,
 
 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,
index 4b217c77041e4ae3cfde171310285ea8c89d3639..e608c1cb5933deee869dbbd4b8a5a948a55c50ab 100644 (file)
@@ -433,7 +433,7 @@ mail_thread_update(struct mail_thread_context *ctx, bool reset)
                } 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 1e02ddedc84317dd78a103c68727f077ee1f53c6..e76a42ecb8934715feae6daa62d1d3002130acad 100644 (file)
@@ -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,
index 8d5186e3e613d569dd40b5a766382ebb272c8790..b4ce350f3bb06c728d7f5c14e11f478bc5b23593 100644 (file)
@@ -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,
index c5697e670a949c0331eb07e85f0652d5f5647cbf..bb57b222de75df2d04e3686e624b6d5ecf5a210d 100644 (file)
@@ -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,
index 5d1c2750f9d7afaad6b717faccaa6e781aedd538..c29524ca1e7f078e82cf746827b677a0e87f7adc 100644 (file)
@@ -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,
index b388a2e7f83550e4b4fb6eacc484f980f56b3a31..309d65bb76a31258355e625d293c2d40f1dce85a 100644 (file)
@@ -629,12 +629,17 @@ mailbox_header_lookup_init(struct mailbox *box, const char *const headers[])
        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 *
index 464c44a04fc47bd191fb364a9076dc767a6e23c7..2fc9513183c4c958d0b54ea51b875197017f3264 100644 (file)
@@ -404,7 +404,8 @@ bool mailbox_get_expunged_uids(struct mailbox *box, uint64_t modseq,
 /* 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 edd1eaaad6002f05b64bf5555248c7955a91ee96..5e1c4318ccb0437f8c9d26cb0604e5134354789f 100644 (file)
@@ -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,
                index_storage_search_init,
                index_storage_search_deinit,
                index_storage_search_next_nonblock,