Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7033:5b40343e96c7 HEAD
Avoid moving raw stream offset.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 22 Dec 2007 05:49:26 +0200 |
parents | 85cf52f0bc64 |
children | e527ac1a7b4b |
files | src/lib-storage/index/mbox/istream-raw-mbox.c src/lib-storage/index/mbox/mbox-mail.c |
diffstat | 2 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/istream-raw-mbox.c Sat Dec 22 05:15:51 2007 +0200 +++ b/src/lib-storage/index/mbox/istream-raw-mbox.c Sat Dec 22 05:49:26 2007 +0200 @@ -475,6 +475,7 @@ (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); @@ -484,12 +485,14 @@ (rstream->body_offset - rstream->hdr_offset); } + old_offset = stream->v_offset; if (body_size != (uoff_t)-1) { i_stream_seek(rstream->istream.parent, rstream->body_offset + body_size); if (istream_raw_mbox_is_valid_from(rstream) > 0) { rstream->mail_size = body_size + (rstream->body_offset - rstream->hdr_offset); + i_stream_seek(stream, old_offset); return body_size; } } @@ -497,6 +500,7 @@ /* 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 -
--- a/src/lib-storage/index/mbox/mbox-mail.c Sat Dec 22 05:15:51 2007 +0200 +++ b/src/lib-storage/index/mbox/mbox-mail.c Sat Dec 22 05:49:26 2007 +0200 @@ -174,12 +174,13 @@ const struct mail_index_header *hdr; struct istream *input; struct message_size hdr_size; - uoff_t body_offset, body_size, next_offset; + uoff_t old_offset, body_offset, body_size, next_offset; if (index_mail_get_physical_size(_mail, size_r) == 0) return 0; /* we want to return the header size as seen by mail_get_stream(). */ + old_offset = data->stream == NULL ? 0 : data->stream->v_offset; if (mail_get_stream(_mail, &hdr_size, NULL, &input) < 0) return -1; @@ -215,6 +216,8 @@ data->physical_size = hdr_size.physical_size + body_size; *size_r = data->physical_size; + + i_stream_seek(input, old_offset); return 0; }