dovecot-2.2: dict-sql: Don't try to optimize finding a matching ...

dovecot at dovecot.org dovecot at dovecot.org
Tue Jun 9 16:34:37 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/1a778838d3e1
changeset: 18832:1a778838d3e1
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jun 09 19:32:09 2015 +0300
description:
dict-sql: Don't try to optimize finding a matching map by using the previous match.
In some setups multiple maps can match and it's important that the matching
is done in the same order always, otherwise the results could become
somewhat random.

diffstat:

 src/lib-dict/dict-sql.c |  13 ++++---------
 1 files changed, 4 insertions(+), 9 deletions(-)

diffs (34 lines):

diff -r 1cebb87f2f8f -r 1a778838d3e1 src/lib-dict/dict-sql.c
--- a/src/lib-dict/dict-sql.c	Fri Jun 05 16:37:24 2015 +0300
+++ b/src/lib-dict/dict-sql.c	Tue Jun 09 19:32:09 2015 +0300
@@ -28,7 +28,6 @@
 	struct sql_db *db;
 	const char *username;
 	const struct dict_sql_settings *set;
-	unsigned int prev_map_match_idx;
 
 	unsigned int has_on_duplicate_key:1;
 };
@@ -190,18 +189,14 @@
 		  ARRAY_TYPE(const_string) *values)
 {
 	const struct dict_sql_map *maps;
-	unsigned int i, idx, count, len;
+	unsigned int i, count, len;
 
 	t_array_init(values, dict->set->max_field_count);
 	maps = array_get(&dict->set->maps, &count);
 	for (i = 0; i < count; i++) {
-		/* start matching from the previously successful match */
-		idx = (dict->prev_map_match_idx + i) % count;
-		if (dict_sql_map_match(&maps[idx], path, values,
-				       &len, &len, FALSE, FALSE)) {
-			dict->prev_map_match_idx = idx;
-			return &maps[idx];
-		}
+		if (dict_sql_map_match(&maps[i], path, values,
+				       &len, &len, FALSE, FALSE))
+			return &maps[i];
 	}
 	return NULL;
 }


More information about the dovecot-cvs mailing list