[dovecot-cvs] dovecot/src/lib-storage/index index-mail-headers.c, 1.63, 1.64 index-mail.c, 1.103, 1.104

cras at dovecot.org cras at dovecot.org
Mon Jul 24 03:26:50 EEST 2006


Update of /var/lib/cvs/dovecot/src/lib-storage/index
In directory talvi:/tmp/cvs-serv28016

Modified Files:
	index-mail-headers.c index-mail.c 
Log Message:
Restore data stream's offset after it has been internally changed, so that
it doesn't have much visible effect on the stream returned by
mail_get_stream(). The buffered data will still be lost, but this should
help with the most common use cases.



Index: index-mail-headers.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail-headers.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- index-mail-headers.c	28 Jun 2006 13:10:49 -0000	1.63
+++ index-mail-headers.c	24 Jul 2006 00:26:47 -0000	1.64
@@ -346,6 +346,9 @@
 			     struct mailbox_header_lookup_ctx *headers)
 {
 	struct index_mail_data *data = &mail->data;
+	uoff_t old_offset;
+
+	old_offset = data->stream == NULL ? 0 : data->stream->v_offset;
 
 	if (mail_get_stream(&mail->mail.mail, NULL, NULL) == NULL)
 		return -1;
@@ -371,6 +374,7 @@
 	data->hdr_size_set = TRUE;
 	data->access_part &= ~PARSE_HDR;
 
+	i_stream_seek(data->stream, old_offset);
 	return 0;
 }
 
@@ -390,6 +394,10 @@
 {
 	struct mailbox_header_lookup_ctx *header_ctx;
 	struct istream *stream;
+	uoff_t old_offset;
+
+	old_offset = mail->data.stream == NULL ? 0 :
+		mail->data.stream->v_offset;
 
 	mail->data.save_envelope = TRUE;
 	header_ctx = mailbox_header_lookup_init(&mail->ibox->box,
@@ -403,6 +411,9 @@
 		mail->data.save_envelope = FALSE;
 	}
 	mailbox_header_lookup_deinit(&header_ctx);
+
+	if (mail->data.stream != NULL)
+		i_stream_seek(mail->data.stream, old_offset);
 }
 
 static size_t get_header_size(buffer_t *buffer, size_t pos)

Index: index-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail.c,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -d -r1.103 -r1.104
--- index-mail.c	3 Jul 2006 11:12:15 -0000	1.103
+++ index-mail.c	24 Jul 2006 00:26:47 -0000	1.104
@@ -297,6 +297,7 @@
 	struct index_mail_data *data = &mail->data;
 	struct mail_cache_field *cache_fields = mail->ibox->cache_fields;
 	struct message_size hdr_size, body_size;
+	uoff_t old_offset;
 
 	if (data->virtual_size != (uoff_t)-1)
 		return data->virtual_size;
@@ -306,8 +307,11 @@
 		return data->virtual_size;
 
 	if (!get_cached_msgpart_sizes(mail)) {
+		old_offset = data->stream == NULL ? 0 : data->stream->v_offset;
+
 		if (mail_get_stream(_mail, &hdr_size, &body_size) == NULL)
 			return (uoff_t)-1;
+		i_stream_seek(data->stream, old_offset);
 	}
 
 	i_assert(data->virtual_size != (uoff_t)-1);
@@ -566,10 +570,12 @@
 				  enum index_cache_field field)
 {
 	struct index_mail_data *data = &mail->data;
+	uoff_t old_offset;
 
 	i_assert(data->parts == NULL);
 	i_assert(data->parser_ctx != NULL);
 
+	old_offset = data->stream->v_offset;
 	i_stream_seek(data->stream, data->hdr_size.physical_size);
 
 	if (data->save_bodystructure_body) {
@@ -585,6 +591,8 @@
 		message_parser_parse_body(data->parser_ctx, NULL, NULL);
 	}
 	index_mail_parse_body_finish(mail, field, FALSE);
+
+	i_stream_seek(data->stream, old_offset);
 }
 
 struct istream *index_mail_init_stream(struct index_mail *_mail,
@@ -665,7 +673,11 @@
 	else {
 		/* body structure is known already, so use it to parse only
 		   the MIME headers */
+		uoff_t old_offset;
+
 		i_assert(data->parts->next == NULL);
+
+		old_offset = data->stream->v_offset;
 		i_stream_seek(data->stream,
 			      data->hdr_size.physical_size);
 
@@ -674,6 +686,7 @@
 					 parse_bodystructure_part_header,
 					 mail->data_pool);
 		data->parsed_bodystructure = TRUE;
+		i_stream_seek(data->stream, old_offset);
 	}
 }
 



More information about the dovecot-cvs mailing list