]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fts: Make sure indexing virtual mailbox doesn't recurse and index mail multiple times
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 3 May 2018 15:30:51 +0000 (18:30 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 11 Jun 2018 12:20:09 +0000 (15:20 +0300)
src/plugins/fts/fts-storage.c

index deda1678540675d4990ebbaf61140e40178fe9ff..cdf1fc50a9d7f5c5d1a8f73646ac5417ea1e8ed8 100644 (file)
@@ -58,6 +58,7 @@ struct fts_transaction_context {
        uint32_t highest_virtual_uid;
        unsigned int precache_extra_count;
 
+       bool indexing:1;
        bool precached:1;
        bool mails_saved:1;
        bool failed:1;
@@ -529,8 +530,12 @@ static void fts_mail_precache(struct mail *_mail)
        if (fmail->virtual_mail) {
                if (ft->highest_virtual_uid < _mail->uid)
                        ft->highest_virtual_uid = _mail->uid;
-       } else T_BEGIN {
+       } else if (!ft->indexing) T_BEGIN {
+               /* avoid recursing here from fts_mail_precache_range() */
+               ft->indexing = TRUE;
                fts_mail_index(_mail);
+               i_assert(ft->indexing);
+               ft->indexing = FALSE;
        } T_END;
 }