From: Vsevolod Stakhov Date: Tue, 19 Jul 2016 11:52:01 +0000 (+0100) Subject: [Fix] Don't mix hyperscan and pcre processing within a same task X-Git-Tag: 1.3.0~49 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e3149270b2f939e9bc47bbbabcb7ad519c0ba1d4;p=rspamd.git [Fix] Don't mix hyperscan and pcre processing within a same task --- diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c index 59070d3da..dc993513c 100644 --- a/src/libserver/re_cache.c +++ b/src/libserver/re_cache.c @@ -109,6 +109,7 @@ struct rspamd_re_runtime { guchar *results; struct rspamd_re_cache *cache; struct rspamd_re_cache_stat stat; + gboolean has_hs; }; static GQuark @@ -441,6 +442,9 @@ rspamd_re_cache_runtime_new (struct rspamd_re_cache *cache) rt->checked = g_slice_alloc0 (NBYTES (cache->nre)); rt->results = g_slice_alloc0 (cache->nre); rt->stat.regexp_total = cache->nre; +#ifdef WITH_HYPERSCAN + rt->has_hs = cache->hyperscan_loaded; +#endif return rt; } @@ -626,7 +630,8 @@ rspamd_re_cache_process_regexp_data (struct rspamd_re_runtime *rt, elt = g_ptr_array_index (rt->cache->re, re_id); re_class = rspamd_regexp_get_class (re); - if (rt->cache->disable_hyperscan || elt->match_type == RSPAMD_RE_CACHE_PCRE) { + if (rt->cache->disable_hyperscan || elt->match_type == RSPAMD_RE_CACHE_PCRE || + !rt->has_hs) { for (i = 0; i < count; i++) { ret = rspamd_re_cache_process_pcre (rt, re, @@ -1023,7 +1028,7 @@ rspamd_re_cache_exec_re (struct rspamd_task *task, } #if WITH_HYPERSCAN - if (!rt->cache->disable_hyperscan) { + if (!rt->cache->disable_hyperscan && rt->has_hs) { rspamd_re_cache_finish_class (rt, re_class); } #endif