Mercurial > dovecot > core-2.2
changeset 13563:690f60827f59
imap: Moved partial fetch cache from static variable into struct client.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 30 Sep 2011 18:19:17 +0300 |
parents | 64d3f748a612 |
children | 5726f89486a0 |
files | src/imap/imap-client.h src/imap/imap-fetch-body.c |
diffstat | 2 files changed, 22 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/imap-client.h Fri Sep 30 15:54:20 2011 +0300 +++ b/src/imap/imap-client.h Fri Sep 30 18:19:17 2011 +0300 @@ -2,6 +2,7 @@ #define IMAP_CLIENT_H #include "imap-commands.h" +#include "message-size.h" #define CLIENT_COMMAND_QUEUE_MAX_SIZE 4 /* Maximum number of CONTEXT=SEARCH UPDATEs. Clients probably won't need more @@ -86,6 +87,15 @@ unsigned int temp_executed:1; /* temporary execution state tracking */ }; +struct partial_fetch_cache { + unsigned int select_counter; + unsigned int uid; + + uoff_t physical_start; + bool cr_skipped; + struct message_size pos; +}; + struct client { struct client *prev, *next; @@ -122,6 +132,8 @@ uint64_t sync_last_full_modseq; uint64_t highest_fetch_modseq; + struct partial_fetch_cache last_partial; + /* SEARCHRES extension: Last saved SEARCH result */ ARRAY_TYPE(seq_range) search_saved_uidset; /* SEARCH=CONTEXT extension: Searches that get updated */
--- a/src/imap/imap-fetch-body.c Fri Sep 30 15:54:20 2011 +0300 +++ b/src/imap/imap-fetch-body.c Fri Sep 30 18:19:17 2011 +0300 @@ -32,17 +32,6 @@ unsigned int peek:1; }; -struct partial_cache { - unsigned int select_counter; - unsigned int uid; - - uoff_t physical_start; - bool cr_skipped; - struct message_size pos; -}; - -static struct partial_cache last_partial = { 0, 0, 0, 0, { 0, 0, 0 } }; - static void fetch_read_error(struct imap_fetch_context *ctx) { errno = ctx->cur_input->stream_errno; @@ -53,7 +42,8 @@ } static int seek_partial(unsigned int select_counter, unsigned int uid, - struct partial_cache *partial, struct istream *stream, + struct partial_fetch_cache *partial, + struct istream *stream, uoff_t virtual_skip, bool *cr_skipped_r) { if (select_counter == partial->select_counter && uid == partial->uid && @@ -236,10 +226,12 @@ ctx->cur_offset += ret; if (ctx->update_partial) { - last_partial.cr_skipped = ctx->skip_cr != 0; - last_partial.pos.physical_size = - ctx->cur_input->v_offset - last_partial.physical_start; - last_partial.pos.virtual_size += ret; + struct partial_fetch_cache *p = &ctx->client->last_partial; + + p->cr_skipped = ctx->skip_cr != 0; + p->pos.physical_size = + ctx->cur_input->v_offset - p->physical_start; + p->pos.virtual_size += ret; } return ctx->cur_offset == ctx->cur_size; @@ -330,8 +322,8 @@ } } else { if (seek_partial(ctx->select_counter, ctx->cur_mail->uid, - &last_partial, ctx->cur_input, body->skip, - &ctx->skip_cr) < 0) { + &ctx->client->last_partial, ctx->cur_input, + body->skip, &ctx->skip_cr) < 0) { fetch_read_error(ctx); return -1; }