dovecot-1.0: Put back mail_get_stream() optimizations now that m...

dovecot at dovecot.org dovecot at dovecot.org
Sat Dec 22 06:53:42 EET 2007


details:   http://hg.dovecot.org/dovecot-1.0/rev/fc5f6bbbf4c0
changeset: 5498:fc5f6bbbf4c0
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Dec 22 06:53:33 2007 +0200
description:
Put back mail_get_stream() optimizations now that mail_get_physical_size()
works properly.

diffstat:

1 file changed, 21 insertions(+), 14 deletions(-)
src/imap/imap-fetch-body.c |   35 +++++++++++++++++++++--------------

diffs (70 lines):

diff -r 0713de760c5f -r fc5f6bbbf4c0 src/imap/imap-fetch-body.c
--- a/src/imap/imap-fetch-body.c	Sat Dec 22 06:51:57 2007 +0200
+++ b/src/imap/imap-fetch-body.c	Sat Dec 22 06:53:33 2007 +0200
@@ -327,13 +327,15 @@ static int fetch_body(struct imap_fetch_
 	struct message_size hdr_size, body_size;
 
 	if (body->section[0] == '\0') {
-		/* FIXME: We really wouldn't have to know header size here
-		   specifically, but with mbox mail_get_physical_size() returns
-		   the real current size on disk, not the size that the stream
-		   has. This may cause virtual_size==physical_size and break
-		   our checks. */
-		ctx->cur_input = mail_get_stream(mail, &hdr_size, &body_size);
-		message_size_add(&body_size, &hdr_size);
+		ctx->cur_input = mail_get_stream(mail, NULL, NULL);
+
+		body_size.virtual_size = mail_get_virtual_size(mail);
+		body_size.physical_size = mail_get_physical_size(mail);
+		if (body_size.virtual_size == (uoff_t)-1 ||
+		    body_size.physical_size == (uoff_t)-1) {
+			ctx->cur_input = NULL;
+			return -1;
+		}
 	} else {
 		ctx->cur_input = mail_get_stream(mail, &hdr_size,
 						 body->section[0] == 'H' ?
@@ -883,22 +885,27 @@ static int fetch_rfc822(struct imap_fetc
 static int fetch_rfc822(struct imap_fetch_context *ctx, struct mail *mail,
 			void *context __attr_unused__)
 {
-	struct message_size hdr_size, body_size;
+	struct message_size size;
 	const char *str;
 
-	ctx->cur_input = mail_get_stream(mail, &hdr_size, &body_size);
+	ctx->cur_input = mail_get_stream(mail, NULL, NULL);
 	if (ctx->cur_input == NULL)
 		return -1;
 
-	/* FIXME: Same problem as with fetch_body() */
-	message_size_add(&body_size, &hdr_size);
+	size.virtual_size = mail_get_virtual_size(mail);
+	size.physical_size = mail_get_physical_size(mail);
+	if (size.virtual_size == (uoff_t)-1 ||
+	    size.physical_size == (uoff_t)-1) {
+		ctx->cur_input = NULL;
+		return -1;
+	}
 
 	i_stream_ref(ctx->cur_input);
 	ctx->update_partial = FALSE;
 
 	if (ctx->cur_offset == 0) {
 		str = t_strdup_printf(" RFC822 {%"PRIuUOFF_T"}\r\n",
-				      body_size.virtual_size);
+				      size.virtual_size);
 		if (ctx->first) {
 			str++; ctx->first = FALSE;
 		}
@@ -906,8 +913,8 @@ static int fetch_rfc822(struct imap_fetc
 			return -1;
 	}
 
-        ctx->cur_size = body_size.virtual_size;
-	return fetch_stream(ctx, &body_size);
+        ctx->cur_size = size.virtual_size;
+	return fetch_stream(ctx, &size);
 }
 
 static int fetch_rfc822_header(struct imap_fetch_context *ctx,


More information about the dovecot-cvs mailing list