aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-19 15:03:11 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-19 15:03:11 +0100
commit808a8d2f49e77b4339a4140b865ee9a671b209ef (patch)
tree4af7d2910a120c30b287c9b5ebc77ece373f47f1 /src
parent67de370681b5d2590609b7509f3899c99db89a84 (diff)
downloadrspamd-808a8d2f49e77b4339a4140b865ee9a671b209ef.tar.gz
rspamd-808a8d2f49e77b4339a4140b865ee9a671b209ef.zip
[Fix] Rework settings to work properly in metric-less configuration
Diffstat (limited to 'src')
-rw-r--r--src/libmime/filter.c18
-rw-r--r--src/lua/lua_task.c35
2 files changed, 28 insertions, 25 deletions
diff --git a/src/libmime/filter.c b/src/libmime/filter.c
index 7ed6ea010..b0f93ec4b 100644
--- a/src/libmime/filter.c
+++ b/src/libmime/filter.c
@@ -106,16 +106,14 @@ insert_metric_result (struct rspamd_task *task,
}
if (task->settings) {
- mobj = ucl_object_lookup (task->settings, metric->name);
- if (mobj) {
- gdouble corr;
-
- sobj = ucl_object_lookup (mobj, symbol);
- if (sobj != NULL && ucl_object_todouble_safe (sobj, &corr)) {
- msg_debug ("settings: changed weight of symbol %s from %.2f to %.2f",
- symbol, w, corr);
- w = corr * flag;
- }
+ mobj = task->settings;
+ gdouble corr;
+
+ sobj = ucl_object_lookup (mobj, symbol);
+ if (sobj != NULL && ucl_object_todouble_safe (sobj, &corr)) {
+ msg_debug ("settings: changed weight of symbol %s from %.2f to %.2f",
+ symbol, w, corr);
+ w = corr * flag;
}
}
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index e522110e1..6d86d316e 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -2471,29 +2471,34 @@ lua_task_set_settings (lua_State *L)
settings = ucl_object_lua_import (L, 2);
if (settings != NULL && task != NULL) {
- task->settings = settings;
metric_elt = ucl_object_lookup (settings, DEFAULT_METRIC);
if (metric_elt) {
- act = ucl_object_lookup (metric_elt, "actions");
+ task->settings = ucl_object_ref (metric_elt);
+ ucl_object_unref (settings);
+ }
+ else {
+ task->settings = settings;
+ }
- if (act) {
- /* Adjust desired actions */
- mres = g_hash_table_lookup (task->results, DEFAULT_METRIC);
+ act = ucl_object_lookup (task->settings, "actions");
- if (mres == NULL) {
- mres = rspamd_create_metric_result (task, DEFAULT_METRIC);
- }
+ if (act) {
+ /* Adjust desired actions */
+ mres = g_hash_table_lookup (task->results, DEFAULT_METRIC);
+
+ if (mres == NULL) {
+ mres = rspamd_create_metric_result (task, DEFAULT_METRIC);
+ }
- for (i = 0; i < METRIC_ACTION_MAX; i++) {
- elt = ucl_object_lookup (act, rspamd_action_to_str (i));
+ for (i = 0; i < METRIC_ACTION_MAX; i++) {
+ elt = ucl_object_lookup (act, rspamd_action_to_str (i));
- if (elt) {
- mres->actions_limits[i] = ucl_object_todouble (elt);
- msg_debug_task ("adjusted action %s to %.2f",
- ucl_object_key (elt), mres->actions_limits[i]);
- }
+ if (elt) {
+ mres->actions_limits[i] = ucl_object_todouble (elt);
+ msg_debug_task ("adjusted action %s to %.2f",
+ ucl_object_key (elt), mres->actions_limits[i]);
}
}
}