aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/re_cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libserver/re_cache.c')
-rw-r--r--src/libserver/re_cache.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c
index 18c463db5..11ad7ba0a 100644
--- a/src/libserver/re_cache.c
+++ b/src/libserver/re_cache.c
@@ -428,6 +428,7 @@ rspamd_re_cache_process_pcre (struct rspamd_re_runtime *rt,
guint r = 0;
const gchar *start = NULL, *end = NULL;
guint max_hits = rspamd_regexp_get_maxhits (re);
+ guint64 id = rspamd_regexp_get_cache_id (re);
if (len == 0) {
len = strlen (in);
@@ -437,26 +438,33 @@ rspamd_re_cache_process_pcre (struct rspamd_re_runtime *rt,
len = rt->cache->max_re_data;
}
- while (rspamd_regexp_search (re,
- in,
- len,
- &start,
- &end,
- is_raw,
- NULL)) {
- r++;
-
- if (max_hits > 0 && r > max_hits) {
- break;
+ r = rt->results[id];
+
+ if (max_hits == 0 || r < max_hits) {
+ while (rspamd_regexp_search (re,
+ in,
+ len,
+ &start,
+ &end,
+ is_raw,
+ NULL)) {
+ r++;
+
+ if (max_hits > 0 && r >= max_hits) {
+ break;
+ }
}
- }
- rt->stat.regexp_checked ++;
- rt->stat.bytes_scanned_pcre += len;
- rt->stat.bytes_scanned += len;
+ rt->stat.regexp_checked++;
+ rt->stat.bytes_scanned_pcre += len;
+ rt->stat.bytes_scanned += len;
- if (r > 0) {
- rt->stat.regexp_matched += r;
+ if (r > 0) {
+ rt->stat.regexp_matched += r;
+ }
+ }
+ else {
+ r = 0;
}
return r;