]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: mail_add_temp_wanted_fields() - delay opening stream
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 25 Jun 2017 06:10:52 +0000 (09:10 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 12 Jul 2017 12:02:18 +0000 (15:02 +0300)
Allows plugins to call it in mail.get_stream() without infinite loop.

src/lib-storage/index/index-mail.c

index 0931bb2eab86951081333a680fad5355670d9f7a..500eb100a0a798b74ae4ccc3da9d241fef503a41 100644 (file)
@@ -2006,7 +2006,16 @@ void index_mail_add_temp_wanted_fields(struct mail *_mail,
                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)