Browse Source

[Fix] Make dynamic conf more NaN aware

tags/1.7.1
Vsevolod Stakhov 6 years ago
parent
commit
8fd4189a09
2 changed files with 28 additions and 7 deletions
  1. 12
    2
      src/controller.c
  2. 16
    5
      src/libserver/dynamic_cfg.c

+ 12
- 2
src/controller.c View File

@@ -2184,8 +2184,18 @@ rspamd_controller_handle_saveactions (
act = METRIC_ACTION_GREYLIST;
break;
}
score = ucl_object_todouble (cur);
if (session->cfg->actions[act].score != score) {

if (ucl_object_type (cur) == UCL_NULL) {
/* Assume NaN */
score = NAN;
}
else {
score = ucl_object_todouble (cur);
}


if ((isnan (session->cfg->actions[act].score) != isnan (score)) ||
(session->cfg->actions[act].score != score)) {
add_dynamic_action (ctx->cfg, DEFAULT_METRIC, act, score);
added ++;
}

+ 16
- 5
src/libserver/dynamic_cfg.c View File

@@ -21,6 +21,8 @@
#include "unix-std.h"
#include "lua/lua_common.h"

#include <math.h>

struct config_json_buf {
GString *buf;
struct rspamd_config *cfg;
@@ -95,9 +97,11 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg)
ucl_object_iter_t nit = NULL;

while ((it_val = ucl_object_iterate (cur_nm, &nit, true))) {
if (ucl_object_lookup (it_val, "name") &&
ucl_object_lookup (it_val, "value")) {
name = ucl_object_tostring (ucl_object_lookup (it_val, "name"));
const ucl_object_t *n = ucl_object_lookup (it_val, "name");
const ucl_object_t *v = ucl_object_lookup (it_val, "value");

if (n != NULL && v != NULL) {
name = ucl_object_tostring (n);

if (!name || !rspamd_action_from_str (name, &test_act)) {
msg_err ("unknown action: %s",
@@ -105,8 +109,15 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg)
"name")));
continue;
}
nscore = ucl_object_todouble (ucl_object_lookup (it_val,
"value"));


if (ucl_object_type (v) == UCL_NULL) {
nscore = NAN;
}
else {
nscore = ucl_object_todouble (v);
}

rspamd_config_set_action_score (cfg, name, nscore, priority);
}
else {

Loading…
Cancel
Save