dovecot-2.2: fts: Avoid expanding mail_search_args multiple time...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jun 15 21:31:45 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/d255f8627d95
changeset: 18862:d255f8627d95
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jun 16 00:29:07 2015 +0300
description:
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

diffstat:

 src/lib-storage/mail-search.h     |  3 +++
 src/plugins/fts/fts-search-args.c |  7 +++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diffs (30 lines):

diff -r 5450f9217b97 -r d255f8627d95 src/lib-storage/mail-search.h
--- 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) \
diff -r 5450f9217b97 -r d255f8627d95 src/plugins/fts/fts-search-args.c
--- 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);


More information about the dovecot-cvs mailing list