changeset 18862:d255f8627d95

fts: Avoid expanding mail_search_args multiple times (for optimization & crash-avoidance) Primarily this fixes the crash: index-search-result.c: line 132 (index_search_result_update_flags): assertion failed: (result->search_args->args == &search_arg) It could be triggered by: a search return (update) body body seen b store 1 +flags \seen c store 1 -flags \seen
author Timo Sirainen <tss@iki.fi>
date Tue, 16 Jun 2015 00:29:07 +0300
parents 5450f9217b97
children a58b3e70fc8a
files src/lib-storage/mail-search.h src/plugins/fts/fts-search-args.c
diffstat 2 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/mail-search.h	Tue Jun 16 00:16:42 2015 +0300
+++ b/src/lib-storage/mail-search.h	Tue Jun 16 00:29:07 2015 +0300
@@ -115,6 +115,9 @@
 	/* Stop mail_search_next() when finding a non-matching mail.
 	   (Could be useful when wanting to find only the oldest mails.) */
 	unsigned int stop_on_nonmatch:1;
+	/* fts plugin has already expanded the search args - no need to do
+	   it again. */
+	unsigned int fts_expanded:1;
 };
 
 #define ARG_SET_RESULT(arg, res) \
--- a/src/plugins/fts/fts-search-args.c	Tue Jun 16 00:16:42 2015 +0300
+++ b/src/plugins/fts/fts-search-args.c	Tue Jun 16 00:29:07 2015 +0300
@@ -185,6 +185,13 @@
 {
 	struct mail_search_arg *args_dup, *orig_args = args->args;
 
+	/* don't keep re-expanding every time the search args are used.
+	   this is especially important to avoid an assert-crash in
+	   index_search_result_update_flags(). */
+	if (args->fts_expanded)
+		return 0;
+	args->fts_expanded = TRUE;
+
 	/* duplicate the args, so if expansion fails we haven't changed
 	   anything */
 	args_dup = mail_search_arg_dup(args->pool, args->args);