[dovecot-cvs] dovecot/src/imap imap-fetch-body-section.c, 1.27,
1.28 imap-fetch.c, 1.20, 1.21 imap-fetch.h, 1.6,
1.7 imap-sort.c, 1.13, 1.14 imap-thread.c, 1.10, 1.11
cras at dovecot.org
cras at dovecot.org
Sun Jul 18 05:25:08 EEST 2004
Update of /home/cvs/dovecot/src/imap
In directory talvi:/tmp/cvs-serv3398/imap
Modified Files:
imap-fetch-body-section.c imap-fetch.c imap-fetch.h
imap-sort.c imap-thread.c
Log Message:
Header caching redesigned. New design allows caching decisions per field, so
they can be divided to temporary/permanent. Cached headers are now always
returned in original order, old code didn't guarantee it. Some other caching
changes. (still missing code to store changes in caching decisions)
Index: imap-fetch-body-section.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/imap-fetch-body-section.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- imap-fetch-body-section.c 17 Jun 2004 21:28:23 -0000 1.27
+++ imap-fetch-body-section.c 18 Jul 2004 02:25:06 -0000 1.28
@@ -254,7 +254,7 @@
if (ctx->dest != NULL)
buffer_append(ctx->dest, str, size);
- if (ctx->output != NULL) {
+ else {
if (o_stream_send(ctx->output, str, size) < 0)
return FALSE;
}
@@ -273,7 +273,9 @@
ctx->match_func = header_match;
if (ctx->fetch_ctx->body_fetch_from_cache) {
- input = ctx->mail->get_headers(ctx->mail, ctx->fields);
+ input = ctx->mail->
+ get_headers(ctx->mail,
+ ctx->fetch_ctx->headers_ctx);
if (input == NULL)
return FALSE;
}
Index: imap-fetch.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/imap-fetch.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- imap-fetch.c 12 Jul 2004 11:35:50 -0000 1.20
+++ imap-fetch.c 18 Jul 2004 02:25:06 -0000 1.21
@@ -347,7 +347,7 @@
struct mail *mail;
struct imap_fetch_body_data *body;
const char *null = NULL;
- const char *const *wanted_headers, *const *arr;
+ const char *const *arr;
buffer_t *buffer;
memset(&ctx, 0, sizeof(ctx));
@@ -375,27 +375,33 @@
/* If we have only BODY[HEADER.FIELDS (...)] fetches, get them
separately rather than parsing the full header so mail storage
can try to cache them. */
- ctx.body_fetch_from_cache = TRUE;
- buffer = buffer_create_dynamic(pool_datastack_create(), 64, (size_t)-1);
- for (body = bodies; body != NULL; body = body->next) {
- if (strncmp(body->section, "HEADER.FIELDS ", 14) != 0) {
- ctx.body_fetch_from_cache = FALSE;
- break;
- }
+ ctx.body_fetch_from_cache = (imap_data & (IMAP_FETCH_RFC822 |
+ IMAP_FETCH_RFC822_HEADER |
+ IMAP_FETCH_RFC822_TEXT)) == 0;
+ if (ctx.body_fetch_from_cache) {
+ buffer = buffer_create_dynamic(pool_datastack_create(),
+ 64, (size_t)-1);
+ for (body = bodies; body != NULL; body = body->next) {
+ if (strncmp(body->section, "HEADER.FIELDS ", 14) != 0) {
+ ctx.body_fetch_from_cache = FALSE;
+ break;
+ }
- arr = imap_fetch_get_body_fields(body->section + 14);
- while (*arr != NULL) {
- buffer_append(buffer, arr, sizeof(*arr));
- arr++;
+ arr = imap_fetch_get_body_fields(body->section + 14);
+ while (*arr != NULL) {
+ buffer_append(buffer, arr, sizeof(*arr));
+ arr++;
+ }
}
+ buffer_append(buffer, &null, sizeof(null));
+ ctx.headers_ctx = !ctx.body_fetch_from_cache ? NULL :
+ mailbox_header_lookup_init(box, buffer_get_data(buffer,
+ NULL));
}
- buffer_append(buffer, &null, sizeof(null));
- wanted_headers = !ctx.body_fetch_from_cache ? NULL :
- buffer_get_data(buffer, NULL);
t = mailbox_transaction_begin(box, TRUE);
ctx.search_ctx = mailbox_search_init(t, NULL, search_args, NULL,
- fetch_data, wanted_headers);
+ fetch_data, ctx.headers_ctx);
if (ctx.search_ctx == NULL)
ctx.failed = TRUE;
else {
@@ -411,6 +417,8 @@
if (mailbox_search_deinit(ctx.search_ctx) < 0)
ctx.failed = TRUE;
}
+ if (ctx.headers_ctx != NULL)
+ mailbox_header_lookup_deinit(ctx.headers_ctx);
if (ctx.failed)
mailbox_transaction_rollback(t);
Index: imap-fetch.h
===================================================================
RCS file: /home/cvs/dovecot/src/imap/imap-fetch.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- imap-fetch.h 27 Apr 2004 20:25:52 -0000 1.6
+++ imap-fetch.h 18 Jul 2004 02:25:06 -0000 1.7
@@ -24,6 +24,7 @@
enum mail_fetch_field fetch_data;
enum imap_fetch_field imap_data;
struct imap_fetch_body_data *bodies;
+ struct mailbox_header_lookup_ctx *headers_ctx;
string_t *str;
struct ostream *output;
Index: imap-sort.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/imap-sort.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- imap-sort.c 10 Jul 2004 11:14:58 -0000 1.13
+++ imap-sort.c 18 Jul 2004 02:25:06 -0000 1.14
@@ -194,6 +194,7 @@
enum mail_sort_type norm_prog[MAX_SORT_PROGRAM_SIZE];
enum mail_fetch_field wanted_fields;
const char *wanted_headers[MAX_WANTED_HEADERS];
+ struct mailbox_header_lookup_ctx *headers_ctx;
struct sort_context *ctx;
struct mail *mail;
buffer_t *buf;
@@ -222,14 +223,17 @@
memset(wanted_headers, 0, sizeof(wanted_headers));
wanted_fields = init_sort_elements(ctx, wanted_headers);
+ headers_ctx = mailbox_header_lookup_init(client->mailbox,
+ wanted_headers);
/* initialize searching */
ctx->t = mailbox_transaction_begin(client->mailbox, FALSE);
ctx->search_ctx =
mailbox_search_init(ctx->t, charset, args, norm_prog,
- wanted_fields, wanted_headers);
+ wanted_fields, headers_ctx);
if (ctx->search_ctx == NULL) {
mailbox_transaction_rollback(ctx->t);
+ mailbox_header_lookup_deinit(headers_ctx);
return -1;
}
@@ -259,6 +263,7 @@
str_len(ctx->str));
}
+ mailbox_header_lookup_deinit(headers_ctx);
mail_sort_deinit(ctx);
return ret;
}
Index: imap-thread.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/imap-thread.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- imap-thread.c 10 Jul 2004 11:14:58 -0000 1.10
+++ imap-thread.c 18 Jul 2004 02:25:06 -0000 1.11
@@ -107,6 +107,7 @@
"message-id", "in-reply-to", "references", "subject",
NULL
};
+ struct mailbox_header_lookup_ctx *headers_ctx;
struct thread_context *ctx;
struct mail *mail;
int ret;
@@ -115,14 +116,17 @@
i_fatal("Only REFERENCES threading supported");
ctx = t_new(struct thread_context, 1);
+ headers_ctx = mailbox_header_lookup_init(client->mailbox,
+ wanted_headers);
/* initialize searching */
ctx->t = mailbox_transaction_begin(client->mailbox, FALSE);
ctx->search_ctx =
mailbox_search_init(ctx->t, charset, args, NULL,
- MAIL_FETCH_DATE, wanted_headers);
+ MAIL_FETCH_DATE, headers_ctx);
if (ctx->search_ctx == NULL) {
mailbox_transaction_rollback(ctx->t);
+ mailbox_header_lookup_deinit(headers_ctx);
return -1;
}
@@ -149,6 +153,8 @@
ret = mailbox_search_deinit(ctx->search_ctx);
if (mailbox_transaction_commit(ctx->t) < 0)
ret = -1;
+
+ mailbox_header_lookup_deinit(headers_ctx);
mail_thread_deinit(ctx);
return ret;
}
More information about the dovecot-cvs
mailing list