}
}
else {
+ if (sdef->cache_item) {
+ /* Check if we can insert this symbol at all */
+ if (!rspamd_symcache_is_item_allowed (task, sdef->cache_item)) {
+ return NULL;
+ }
+ }
+
final_score = (*sdef->weight_ptr) * weight;
PTR_ARRAY_FOREACH (sdef->groups, i, gr) {
flags);
/* Process cache item */
- if (task->cfg->cache) {
- rspamd_symcache_inc_frequency (task->cfg->cache, symbol);
+ if (task->cfg->cache && s->sym) {
+ rspamd_symcache_inc_frequency (task->cfg->cache, s->sym->cache_item);
}
return s;
void
rspamd_symcache_inc_frequency (struct rspamd_symcache *cache,
- const gchar *symbol)
+ struct rspamd_symcache_item *item)
{
- struct rspamd_symcache_item *item;
-
- g_assert (cache != NULL);
-
- item = g_hash_table_lookup (cache->items_by_symbol, symbol);
-
if (item != NULL) {
g_atomic_int_inc (&item->st->hits);
}
item = rspamd_symcache_find_filter (cache, symbol, true);
if (item) {
- dyn_item = rspamd_symcache_get_dynamic (checkpoint, item);
- if (CHECK_START_BIT (checkpoint, dyn_item)) {
+
+ if (!rspamd_symcache_is_item_allowed (task, item)) {
ret = FALSE;
}
else {
- if (item->specific.normal.condition_cb != -1) {
- /* We also executes condition callback to check if we need this symbol */
- L = task->cfg->lua_state;
- lua_rawgeti (L, LUA_REGISTRYINDEX,
- item->specific.normal.condition_cb);
- ptask = lua_newuserdata (L, sizeof (struct rspamd_task *));
- rspamd_lua_setclass (L, "rspamd{task}", -1);
- *ptask = task;
-
- if (lua_pcall (L, 1, 1, 0) != 0) {
- msg_info_task ("call to condition for %s failed: %s",
- item->symbol, lua_tostring (L, -1));
- lua_pop (L, 1);
- }
- else {
- ret = lua_toboolean (L, -1);
- lua_pop (L, 1);
+ dyn_item = rspamd_symcache_get_dynamic (checkpoint, item);
+ if (CHECK_START_BIT (checkpoint, dyn_item)) {
+ ret = FALSE;
+ }
+ else {
+ if (item->specific.normal.condition_cb != -1) {
+ /*
+ * We also executes condition callback to check
+ * if we need this symbol
+ */
+ L = task->cfg->lua_state;
+ lua_rawgeti (L, LUA_REGISTRYINDEX,
+ item->specific.normal.condition_cb);
+ ptask = lua_newuserdata (L, sizeof (struct rspamd_task *));
+ rspamd_lua_setclass (L, "rspamd{task}", -1);
+ *ptask = task;
+
+ if (lua_pcall (L, 1, 1, 0) != 0) {
+ msg_info_task ("call to condition for %s failed: %s",
+ item->symbol, lua_tostring (L, -1));
+ lua_pop (L, 1);
+ }
+ else {
+ ret = lua_toboolean (L, -1);
+ lua_pop (L, 1);
+ }
}
}
}