dovecot-2.1: imap: Moved partial fetch cache from static variabl...

dovecot at dovecot.org dovecot at dovecot.org
Fri Sep 30 18:10:57 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/690f60827f59
changeset: 13563:690f60827f59
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Sep 30 18:19:17 2011 +0300
description:
imap: Moved partial fetch cache from static variable into struct client.

diffstat:

 src/imap/imap-client.h     |  12 ++++++++++++
 src/imap/imap-fetch-body.c |  28 ++++++++++------------------
 2 files changed, 22 insertions(+), 18 deletions(-)

diffs (95 lines):

diff -r 64d3f748a612 -r 690f60827f59 src/imap/imap-client.h
--- 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 */
diff -r 64d3f748a612 -r 690f60827f59 src/imap/imap-fetch-body.c
--- 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;
 		}


More information about the dovecot-cvs mailing list