aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-10-11 14:32:11 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-10-11 14:32:11 +0100
commitf5051a01e8d0c622682f8a282b818ff3a31be01a (patch)
tree44744ac6cdb87336b63182d87cc8b54a79a034c0 /src
parent0f9f675d64ce090b4e23397c29635f83dd4b457c (diff)
downloadrspamd-f5051a01e8d0c622682f8a282b818ff3a31be01a.tar.gz
rspamd-f5051a01e8d0c622682f8a282b818ff3a31be01a.zip
[Rework] Always create result for a task
Diffstat (limited to 'src')
-rw-r--r--src/libmime/filter.c2
-rw-r--r--src/libmime/filter.h3
-rw-r--r--src/libmime/message.c2
-rw-r--r--src/libserver/symbols_cache.c2
-rw-r--r--src/libserver/task.c2
-rw-r--r--src/libserver/task.h6
-rw-r--r--src/lua/lua_task.c11
7 files changed, 7 insertions, 21 deletions
diff --git a/src/libmime/filter.c b/src/libmime/filter.c
index 81f8818bb..cdbfdcfbf 100644
--- a/src/libmime/filter.c
+++ b/src/libmime/filter.c
@@ -123,7 +123,7 @@ insert_metric_result (struct rspamd_task *task,
gboolean single = !!(flags & RSPAMD_SYMBOL_INSERT_SINGLE);
gchar *sym_cpy;
- metric_res = rspamd_create_metric_result (task);
+ metric_res = task->result;
if (!isfinite (weight)) {
msg_warn_task ("detected %s score for symbol %s, replace it with zero",
diff --git a/src/libmime/filter.h b/src/libmime/filter.h
index 5a7cecb68..9137258f5 100644
--- a/src/libmime/filter.h
+++ b/src/libmime/filter.h
@@ -59,8 +59,9 @@ KHASH_INIT (rspamd_symbols_group_hash,
rspamd_ptr_hash_func,
rspamd_ptr_equal_func);
struct rspamd_metric_result {
- double score; /**< total score */
+ double score; /**< total score */
double grow_factor; /**< current grow factor */
+
khash_t(rspamd_symbols_hash) *symbols; /**< symbols of metric */
khash_t(rspamd_symbols_group_hash) *sym_groups; /**< groups of symbols */
gdouble actions_limits[METRIC_ACTION_MAX]; /**< set of actions for this metric */
diff --git a/src/libmime/message.c b/src/libmime/message.c
index a5dec9775..4206211c1 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -856,7 +856,7 @@ rspamd_message_process_text_part_maybe (struct rspamd_task *task,
if (act != METRIC_ACTION_NOACTION) {
struct rspamd_metric_result *mres;
- mres = rspamd_create_metric_result (task);
+ mres = task->result;
if (mres != NULL) {
if (act == METRIC_ACTION_REJECT) {
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index 0bd90ec70..9cd52458b 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -1607,7 +1607,7 @@ rspamd_symbols_cache_make_checkpoint (struct rspamd_task *task,
checkpoint->pass = RSPAMD_CACHE_PASS_INIT;
task->checkpoint = checkpoint;
- task->result = rspamd_create_metric_result (task);
+ task->result = task->result;
return checkpoint;
}
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 0fde93f55..42d9b1789 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -145,7 +145,7 @@ rspamd_task_new (struct rspamd_worker *worker, struct rspamd_config *cfg,
new_task->sock = -1;
new_task->flags |= (RSPAMD_TASK_FLAG_MIME|RSPAMD_TASK_FLAG_JSON);
- new_task->pre_result.action = METRIC_ACTION_MAX;
+ new_task->result = rspamd_create_metric_result (new_task);
new_task->message_id = new_task->queue_id = "undef";
new_task->messages = ucl_object_typed_new (UCL_OBJECT);
diff --git a/src/libserver/task.h b/src/libserver/task.h
index b9fd2f811..c1eec96ed 100644
--- a/src/libserver/task.h
+++ b/src/libserver/task.h
@@ -201,12 +201,6 @@ struct rspamd_task {
struct event *guard_ev; /**< Event for input sanity guard */
gpointer checkpoint; /**< Opaque checkpoint data */
-
- struct {
- gint action; /**< Action of pre filters */
- gchar *str; /**< String describing action */
- } pre_result; /**< Result of pre-filters */
-
ucl_object_t *settings; /**< Settings applied to task */
const gchar *classifier; /**< Classifier to learn (if needed) */
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 1fb7313c0..7f2711e19 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -1586,9 +1586,6 @@ lua_task_set_pre_result (lua_State * L)
if (action < METRIC_ACTION_MAX && action >= METRIC_ACTION_REJECT) {
/* We also need to set the default metric to that result */
- if (!task->result) {
- task->result = rspamd_create_metric_result (task);
- }
task->pre_result.action = action;
@@ -4127,10 +4124,6 @@ lua_task_set_settings (lua_State *L)
/* Adjust desired actions */
mres = task->result;
- if (mres == NULL) {
- mres = rspamd_create_metric_result (task);
- }
-
for (i = 0; i < METRIC_ACTION_MAX; i++) {
elt = ucl_object_lookup_any (act, rspamd_action_to_str (i),
rspamd_action_to_str_alt (i), NULL);
@@ -4543,9 +4536,7 @@ lua_task_get_metric_action (lua_State *L)
enum rspamd_action_type action;
if (task) {
- if ((metric_res = task->result) == NULL) {
- metric_res = rspamd_create_metric_result (task);
- }
+ metric_res = task->result;
action = rspamd_check_action_metric (task, metric_res);
lua_pushstring (L, rspamd_action_to_str (action));