aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_task.c
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/lua/lua_task.c
parent67de370681b5d2590609b7509f3899c99db89a84 (diff)
downloadrspamd-808a8d2f49e77b4339a4140b865ee9a671b209ef.tar.gz
rspamd-808a8d2f49e77b4339a4140b865ee9a671b209ef.zip
[Fix] Rework settings to work properly in metric-less configuration
Diffstat (limited to 'src/lua/lua_task.c')
-rw-r--r--src/lua/lua_task.c35
1 files changed, 20 insertions, 15 deletions
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]);
}
}
}