aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/expressions.c20
-rw-r--r--src/expressions.h4
-rw-r--r--src/worker.c2
3 files changed, 18 insertions, 8 deletions
diff --git a/src/expressions.c b/src/expressions.c
index e86802a1f..07f1c45fb 100644
--- a/src/expressions.c
+++ b/src/expressions.c
@@ -105,17 +105,27 @@ re_cache_add (char *line, void *pointer)
/* 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;
}
diff --git a/src/expressions.h b/src/expressions.h
index 06034c485..6ee5d97e9 100644
--- a/src/expressions.h
+++ b/src/expressions.h
@@ -101,7 +101,7 @@ void * re_cache_check (const char *line);
* @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
@@ -109,7 +109,7 @@ void task_cache_add (struct worker_task *task, void *pointer, int32_t result);
* @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)
diff --git a/src/worker.c b/src/worker.c
index 5242c0087..e97454121 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -291,7 +291,7 @@ accept_socket (int fd, short what, void *arg)
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 ++;