"re_cache", cache->hash, \
G_STRFUNC, \
__VA_ARGS__)
+#define msg_debug_re_task(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \
+ "re_cache", task->task_pool->tag.uid, \
+ G_STRFUNC, \
+ __VA_ARGS__)
#ifdef WITH_HYPERSCAN
#define RSPAMD_HS_MAGIC_LEN (sizeof (rspamd_hs_magic))
static guint
rspamd_re_cache_process_pcre (struct rspamd_re_runtime *rt,
- rspamd_regexp_t *re, rspamd_mempool_t *pool,
+ rspamd_regexp_t *re, struct rspamd_task *task,
const guchar *in, gsize len,
gboolean is_raw)
{
is_raw,
NULL)) {
r++;
+ msg_debug_re_task ("found regexp /%s/, total hits: %d",
+ rspamd_regexp_get_pattern (re), r);
if (max_hits > 0 && r >= max_hits) {
break;
t2 = rspamd_get_ticks ();
if (t2 - t1 > slow_time) {
- msg_info_pool ("regexp '%16s' took %.2f seconds to execute",
+ msg_info_task ("regexp '%16s' took %.2f seconds to execute",
rspamd_regexp_get_pattern (re), t2 - t1);
}
}
const guint *lens;
guint count;
rspamd_regexp_t *re;
- rspamd_mempool_t *pool;
+ struct rspamd_task *task;
};
static gint
struct rspamd_re_runtime *rt;
struct rspamd_re_cache_elt *pcre_elt;
guint ret, maxhits, i, processed;
+ struct rspamd_task *task;
rt = cbdata->rt;
+ task = cbdata->task;
pcre_elt = g_ptr_array_index (rt->cache->re, id);
maxhits = rspamd_regexp_get_maxhits (pcre_elt->re);
rt->results[id] += ret;
rt->stat.regexp_matched++;
}
+ msg_debug_re_task ("found regexp /%s/ using hyperscan only, total hits: %d",
+ rspamd_regexp_get_pattern (pcre_elt->re), rt->results[id]);
}
else {
if (!isset (rt->checked, id)) {
for (i = 0; i < cbdata->count; i ++) {
ret = rspamd_re_cache_process_pcre (rt,
pcre_elt->re,
- cbdata->pool,
+ cbdata->task,
cbdata->ins[i],
cbdata->lens[i],
FALSE);
static guint
rspamd_re_cache_process_regexp_data (struct rspamd_re_runtime *rt,
- rspamd_regexp_t *re, rspamd_mempool_t *pool,
+ rspamd_regexp_t *re, struct rspamd_task *task,
const guchar **in, guint *lens,
guint count,
gboolean is_raw)
for (i = 0; i < count; i++) {
ret = rspamd_re_cache_process_pcre (rt,
re,
- pool,
+ task,
in[i],
lens[i],
is_raw);
cbdata.rt = rt;
cbdata.lens = &lens[i];
cbdata.count = 1;
- cbdata.pool = pool;
+ cbdata.task = task;
if ((hs_scan (re_class->hs_db, in[i], lens[i], 0,
re_class->hs_scratch,
cbdata.rt = rt;
cbdata.lens = lens;
cbdata.count = 1;
- cbdata.pool = pool;
+ cbdata.task = task;
if ((hs_scan_vector (re_class->hs_db, (const char **)in, lens, count, 0,
re_class->hs_scratch,
gboolean raw = FALSE;
struct rspamd_mime_text_part *part;
struct rspamd_url *url;
- struct rspamd_re_cache *cache = rt->cache;
gpointer k, v;
guint len, cnt;
- msg_debug_re_cache ("get to the slow path for re type: %s: %s",
+ msg_debug_re_task ("check re type: %s: /%s/",
rspamd_re_cache_type_to_string (re_class->type),
rspamd_regexp_get_pattern (re));
re_id = rspamd_regexp_get_cache_id (re);
}
ret = rspamd_re_cache_process_regexp_data (rt, re,
- task->task_pool, scvec, lenvec, headerlist->len, raw);
- debug_task ("checking header %s regexp: %s -> %d",
+ task, scvec, lenvec, headerlist->len, raw);
+ msg_debug_re_task ("checking header %s regexp: %s -> %d",
re_class->type_data,
rspamd_regexp_get_pattern (re), ret);
g_free (scvec);
in = task->raw_headers_content.begin;
len = task->raw_headers_content.len;
ret = rspamd_re_cache_process_regexp_data (rt, re,
- task->task_pool, (const guchar **)&in, &len, 1, raw);
- debug_task ("checking allheader regexp: %s -> %d",
+ task, (const guchar **)&in, &len, 1, raw);
+ msg_debug_re_task ("checking allheader regexp: %s -> %d",
rspamd_regexp_get_pattern (re), ret);
break;
case RSPAMD_RE_MIMEHEADER:
}
ret = rspamd_re_cache_process_regexp_data (rt, re,
- task->task_pool, scvec, lenvec, headerlist->len, raw);
- debug_task ("checking mime header %s regexp: %s -> %d",
+ task, scvec, lenvec, headerlist->len, raw);
+ msg_debug_re_task ("checking mime header %s regexp: %s -> %d",
re_class->type_data,
rspamd_regexp_get_pattern (re), ret);
g_free (scvec);
}
ret = rspamd_re_cache_process_regexp_data (rt, re,
- task->task_pool, scvec, lenvec, cnt, raw);
- debug_task ("checking mime regexp: %s -> %d",
+ task, scvec, lenvec, cnt, raw);
+ msg_debug_re_task ("checking mime regexp: %s -> %d",
rspamd_regexp_get_pattern (re), ret);
g_free (scvec);
g_free (lenvec);
g_assert (i == cnt);
ret = rspamd_re_cache_process_regexp_data (rt, re,
- task->task_pool, scvec, lenvec, i, raw);
- debug_task ("checking url regexp: %s -> %d",
+ task, scvec, lenvec, i, raw);
+ msg_debug_re_task ("checking url regexp: %s -> %d",
rspamd_regexp_get_pattern (re), ret);
g_free (scvec);
g_free (lenvec);
in = task->msg.begin;
len = task->msg.len;
- ret = rspamd_re_cache_process_regexp_data (rt, re, task->task_pool,
+ ret = rspamd_re_cache_process_regexp_data (rt, re, task,
(const guchar **)&in, &len, 1, raw);
- debug_task ("checking rawbody regexp: %s -> %d",
+ msg_debug_re_task ("checking rawbody regexp: %s -> %d",
rspamd_regexp_get_pattern (re), ret);
break;
case RSPAMD_RE_SABODY:
}
ret = rspamd_re_cache_process_regexp_data (rt, re,
- task->task_pool, scvec, lenvec, cnt, TRUE);
- debug_task ("checking sa body regexp: %s -> %d",
+ task, scvec, lenvec, cnt, TRUE);
+ msg_debug_re_task ("checking sa body regexp: %s -> %d",
rspamd_regexp_get_pattern (re), ret);
g_free (scvec);
g_free (lenvec);
}
ret = rspamd_re_cache_process_regexp_data (rt, re,
- task->task_pool, scvec, lenvec, cnt, TRUE);
- debug_task ("checking sa rawbody regexp: %s -> %d",
+ task, scvec, lenvec, cnt, TRUE);
+ msg_debug_re_task ("checking sa rawbody regexp: %s -> %d",
rspamd_regexp_get_pattern (re), ret);
g_free (scvec);
g_free (lenvec);