dovecot-1.0: Added some kludges so that mbox input streams won't...

dovecot at dovecot.org dovecot at dovecot.org
Fri Dec 28 18:39:55 EET 2007


details:   http://hg.dovecot.org/dovecot-1.0/rev/0a4f86976f50
changeset: 5499:0a4f86976f50
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Dec 28 18:39:51 2007 +0200
description:
Added some kludges so that mbox input streams won't read data from wrong
offset. This is properly fixed in v1.1 tree.

diffstat:

2 files changed, 13 insertions(+), 4 deletions(-)
src/lib-storage/index/mbox/istream-raw-mbox.c |   10 ++++++++--
src/lib-storage/index/mbox/mbox-mail.c        |    7 +++++--

diffs (76 lines):

diff -r fc5f6bbbf4c0 -r 0a4f86976f50 src/lib-storage/index/mbox/istream-raw-mbox.c
--- a/src/lib-storage/index/mbox/istream-raw-mbox.c	Sat Dec 22 06:53:33 2007 +0200
+++ b/src/lib-storage/index/mbox/istream-raw-mbox.c	Fri Dec 28 18:39:51 2007 +0200
@@ -327,8 +327,11 @@ static void _sync(struct _istream *strea
 
 	i_stream_sync(rstream->input);
 
-	rstream->istream.skip = 0;
-	rstream->istream.pos = 0;
+	stream->skip = stream->pos = 0;
+	stream->buffer = NULL;
+
+        rstream->input_peak_offset = 0;
+	rstream->eof = FALSE;
 }
 
 static const struct stat *_stat(struct _istream *stream, bool exact)
@@ -477,6 +480,7 @@ uoff_t istream_raw_mbox_get_body_size(st
 		(struct raw_mbox_istream *)stream->real_stream;
 	const unsigned char *data;
 	size_t size;
+	uoff_t old_offset;
 
 	i_assert(rstream->hdr_offset != (uoff_t)-1);
 	i_assert(rstream->body_offset != (uoff_t)-1);
@@ -486,6 +490,7 @@ uoff_t istream_raw_mbox_get_body_size(st
 			(rstream->body_offset - rstream->hdr_offset);
 	}
 
+	old_offset = stream->v_offset;
 	if (body_size != (uoff_t)-1) {
 		i_stream_seek(rstream->input, rstream->body_offset + body_size);
 		if (istream_raw_mbox_is_valid_from(rstream) > 0) {
@@ -498,6 +503,7 @@ uoff_t istream_raw_mbox_get_body_size(st
 	/* have to read through the message body */
 	while (i_stream_read_data(stream, &data, &size, 0) > 0)
 		i_stream_skip(stream, size);
+	i_stream_seek(stream, old_offset);
 
 	i_assert(rstream->mail_size != (uoff_t)-1);
 	return rstream->mail_size -
diff -r fc5f6bbbf4c0 -r 0a4f86976f50 src/lib-storage/index/mbox/mbox-mail.c
--- a/src/lib-storage/index/mbox/mbox-mail.c	Sat Dec 22 06:53:33 2007 +0200
+++ b/src/lib-storage/index/mbox/mbox-mail.c	Fri Dec 28 18:39:51 2007 +0200
@@ -160,7 +160,7 @@ static uoff_t mbox_mail_get_physical_siz
 	const struct mail_index_header *hdr;
 	struct istream *input;
 	struct message_size hdr_size;
-	uoff_t size, body_offset, body_size, next_offset;
+	uoff_t size, body_offset, body_size, next_offset, old_offset;
 	bool deleted;
 
 	size = index_mail_get_physical_size(_mail);
@@ -168,9 +168,11 @@ static uoff_t mbox_mail_get_physical_siz
 		return size;
 
 	/* we want to return the header size as seen by mail_get_stream(). */
+	old_offset = data->stream == NULL ? 0 : data->stream->v_offset;
 	input = mail_get_stream(_mail, &hdr_size, NULL);
 	if (input == NULL)
 		return (uoff_t)-1;
+	i_stream_sync(mbox->mbox_stream);
 
 	/* our header size varies, so don't do any caching */
 	body_offset = istream_raw_mbox_get_body_offset(mbox->mbox_stream);
@@ -201,8 +203,9 @@ static uoff_t mbox_mail_get_physical_siz
 						   body_size);
 
 	data->physical_size = hdr_size.physical_size + body_size;
+	i_stream_seek(data->stream, old_offset);
+	i_stream_sync(mbox->mbox_stream);
 	return data->physical_size;
-
 }
 
 static struct istream *mbox_mail_get_stream(struct mail *_mail,


More information about the dovecot-cvs mailing list