/* Task cache functions */
void
-task_cache_add (struct worker_task *task, void *pointer, int32_t result)
+task_cache_add (struct worker_task *task, struct rspamd_regexp *re, int32_t result)
{
- g_hash_table_insert (task->re_cache, pointer, GINT_TO_POINTER (result));
+ if (result == 0) {
+ result = -1;
+ }
+
+ g_hash_table_insert (task->re_cache, re->regexp_text, GINT_TO_POINTER (result));
}
int32_t
-task_cache_check (struct worker_task *task, void *pointer)
+task_cache_check (struct worker_task *task, struct rspamd_regexp *re)
{
gpointer res;
- if ((res = g_hash_table_lookup (task->re_cache, pointer)) != NULL) {
- return GPOINTER_TO_INT (res);
+ int32_t r;
+
+ if ((res = g_hash_table_lookup (task->re_cache, re->regexp_text)) != NULL) {
+ r = GPOINTER_TO_INT (res);
+ if (r == -1) {
+ return 0;
+ }
+ return 1;
}
return -1;
}
* @param pointer regexp data
* @param result numeric result of this regexp
*/
-void task_cache_add (struct worker_task *task, void *pointer, int32_t result);
+void task_cache_add (struct worker_task *task, struct rspamd_regexp *re, int32_t result);
/**
* Check regexp in cache
* @param pointer regexp data
* @return numeric result if value exists or -1 if not
*/
-int32_t task_cache_check (struct worker_task *task, void *pointer);
+int32_t task_cache_check (struct worker_task *task, struct rspamd_regexp *re);
/**
* Parse and return a single function argument for a function (may recurse)
memory_pool_add_destructor (new_task->task_pool, (pool_destruct_func)rcpt_destruct, new_task);
new_task->results = g_hash_table_new (g_str_hash, g_str_equal);
memory_pool_add_destructor (new_task->task_pool, (pool_destruct_func)g_hash_table_destroy, new_task->results);
- new_task->re_cache = g_hash_table_new (g_direct_hash, g_direct_equal);
+ new_task->re_cache = g_hash_table_new (g_str_hash, g_str_equal);
memory_pool_add_destructor (new_task->task_pool, (pool_destruct_func)g_hash_table_destroy, new_task->re_cache);
worker->srv->stat->connections_count ++;