changeset 22307:77aa19dcceee

lib-storage: mail_add_temp_wanted_fields() - delay opening stream Allows plugins to call it in mail.get_stream() without infinite loop.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sun, 25 Jun 2017 09:10:52 +0300
parents 8459df27194b
children 7302145e3f53
files src/lib-storage/index/index-mail.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/index-mail.c	Tue May 03 00:25:43 2016 +0300
+++ b/src/lib-storage/index/index-mail.c	Sun Jun 25 09:10:52 2017 +0300
@@ -2006,7 +2006,16 @@
 		data->wanted_headers = new_wanted_headers;
 	}
 	index_mail_update_access_parts_pre(_mail);
-	index_mail_update_access_parts_post(_mail);
+	/* Don't call _post(), which would try to open the stream. It should be
+	   enough to delay the opening until it happens anyway.
+
+	   Otherwise there's not really any good place to call this in the
+	   plugins: set_seq() call get_stream() internally, which can already
+	   start parsing the headers, so it's too late. If we use get_stream()
+	   and there's a _post() call here, it gets into infinite loop. The
+	   loop could probably be prevented in some way, but it's probably
+	   better to eventually try to remove the _post() call entirely
+	   everywhere. */
 }
 
 void index_mail_set_uid_cache_updates(struct mail *_mail, bool set)