diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-07 22:46:13 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-07 22:46:13 +0000 |
commit | ed492b2b9f25474c7faa3fffbc9abe0328733278 (patch) | |
tree | 4499163b17300f6085750fb52e8ea26aafec1d5f /src/libmime | |
parent | 52285ba801090d1fad15060d6b1a61460dcbdc36 (diff) | |
download | rspamd-ed492b2b9f25474c7faa3fffbc9abe0328733278.tar.gz rspamd-ed492b2b9f25474c7faa3fffbc9abe0328733278.zip |
Fix cache usage for rspamd_regexp.
Diffstat (limited to 'src/libmime')
-rw-r--r-- | src/libmime/expressions.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/libmime/expressions.c b/src/libmime/expressions.c index aab78df5c..547cc0d58 100644 --- a/src/libmime/expressions.c +++ b/src/libmime/expressions.c @@ -653,6 +653,7 @@ parse_regexp (rspamd_mempool_t * pool, const gchar *line, gboolean raw_mode) const gchar *begin, *end, *p, *src, *start; gchar *dbegin, *dend; struct rspamd_regexp_element *result; + rspamd_regexp_t *re; GError *err = NULL; GString *re_flags; @@ -661,6 +662,10 @@ parse_regexp (rspamd_mempool_t * pool, const gchar *line, gboolean raw_mode) return NULL; } + if ((re = rspamd_regexp_cache_query (NULL, line, NULL)) != NULL) { + return ((struct rspamd_regexp_element *)rspamd_regexp_get_ud (re)); + } + src = line; result = rspamd_mempool_alloc0 (pool, sizeof (struct rspamd_regexp_element)); /* Skip whitespaces */ @@ -798,7 +803,7 @@ parse_regexp (rspamd_mempool_t * pool, const gchar *line, gboolean raw_mode) g_string_append_c (re_flags, 'r'); } - result->regexp = rspamd_regexp_cache_create (NULL, dbegin, re_flags->str, + result->regexp = rspamd_regexp_new (dbegin, re_flags->str, &err); g_string_free (re_flags, TRUE); @@ -814,6 +819,10 @@ parse_regexp (rspamd_mempool_t * pool, const gchar *line, gboolean raw_mode) (rspamd_mempool_destruct_t) rspamd_regexp_unref, (void *)result->regexp); + rspamd_regexp_set_ud (result->regexp, result); + + rspamd_regexp_cache_insert (NULL, line, NULL, result->regexp); + *dend = '/'; return result; |