static guint
rspamd_re_cache_process_pcre (struct rspamd_re_runtime *rt,
- rspamd_regexp_t *re, const guchar *in, gsize len,
+ rspamd_regexp_t *re, rspamd_mempool_t *pool,
+ const guchar *in, gsize len,
gboolean is_raw)
{
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);
+ gdouble t1, t2;
+ const gdouble slow_time = 0.1;
if (len == 0) {
len = strlen (in);
r = rt->results[id];
+ t1 = rspamd_get_ticks ();
+
if (max_hits == 0 || r < max_hits) {
while (rspamd_regexp_search (re,
in,
}
}
+ t2 = rspamd_get_ticks ();
+
+ if (t2 - t1 > slow_time) {
+ msg_info_pool ("regexp '%16s' took %.2f seconds to execute",
+ rspamd_regexp_get_pattern (re), t2 - t1);
+ }
+
return r;
}
const guchar *in;
gsize len;
rspamd_regexp_t *re;
+ rspamd_mempool_t *pool;
};
static gint
if (!isset (rt->checked, id)) {
ret = rspamd_re_cache_process_pcre (rt,
pcre_elt->re,
+ cbdata->pool,
cbdata->in,
cbdata->len,
FALSE);
static guint
rspamd_re_cache_process_regexp_data (struct rspamd_re_runtime *rt,
- rspamd_regexp_t *re,
+ rspamd_regexp_t *re, rspamd_mempool_t *pool,
const guchar *in, gsize len,
gboolean is_raw)
{
}
#ifndef WITH_HYPERSCAN
- ret = rspamd_re_cache_process_pcre (rt, re, in, len, is_raw);
+ ret = rspamd_re_cache_process_pcre (rt, re, pool, in, len, is_raw);
setbit (rt->checked, re_id);
rt->results[re_id] = ret;
#else
re_class = rspamd_regexp_get_class (re);
if (rt->cache->disable_hyperscan || elt->match_type == RSPAMD_RE_CACHE_PCRE) {
- ret = rspamd_re_cache_process_pcre (rt, re, in, len, is_raw);
+ ret = rspamd_re_cache_process_pcre (rt, re, pool, in, len, is_raw);
setbit (rt->checked, re_id);
rt->results[re_id] = ret;
}
cbdata.re = re;
cbdata.rt = rt;
cbdata.len = len;
+ cbdata.pool = pool;
rt->stat.bytes_scanned += len;
if ((hs_scan (re_class->hs_db, in, len, 0, re_class->hs_scratch,
/* Match re */
if (in) {
- ret = rspamd_re_cache_process_regexp_data (rt, re, in,
- strlen (in), raw);
+ ret = rspamd_re_cache_process_regexp_data (rt, re,
+ task->task_pool, in, strlen (in), raw);
debug_task ("checking header %s regexp: %s -> %d",
re_class->type_data,
rspamd_regexp_get_pattern (re), ret);
raw = TRUE;
in = task->raw_headers_content.begin;
len = task->raw_headers_content.len;
- ret = rspamd_re_cache_process_regexp_data (rt, re, in,
- len, raw);
+ ret = rspamd_re_cache_process_regexp_data (rt, re,
+ task->task_pool, in, len, raw);
debug_task ("checking allheader regexp: %s -> %d",
rspamd_regexp_get_pattern (re), ret);
break;
}
if (len > 0) {
- ret = rspamd_re_cache_process_regexp_data (rt, re, in,
- len, raw);
+ ret = rspamd_re_cache_process_regexp_data (rt, re,
+ task->task_pool, in, len, raw);
debug_task ("checking mime regexp: %s -> %d",
rspamd_regexp_get_pattern (re), ret);
}
len = url->urllen;
raw = FALSE;
- ret = rspamd_re_cache_process_regexp_data (rt, re, in,
- len, raw);
+ ret = rspamd_re_cache_process_regexp_data (rt, re,
+ task->task_pool, in, len, raw);
}
g_hash_table_iter_init (&it, task->emails);
len = url->urllen;
raw = FALSE;
- ret = rspamd_re_cache_process_regexp_data (rt, re, in,
- len, raw);
+ ret = rspamd_re_cache_process_regexp_data (rt, re,
+ task->task_pool, in, len, raw);
}
debug_task ("checking url regexp: %s -> %d",
in = task->msg.begin;
len = task->msg.len;
- ret = rspamd_re_cache_process_regexp_data (rt, re, in,
+ ret = rspamd_re_cache_process_regexp_data (rt, re, task->task_pool, in,
len, raw);
debug_task ("checking rawbody regexp: %s -> %d",
rspamd_regexp_get_pattern (re), ret);