}
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;
}
}
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]);
}
}
}