From: Vsevolod Stakhov Date: Thu, 17 Aug 2023 11:22:48 +0000 (+0100) Subject: [Minor] Fix some more issues X-Git-Tag: 3.7.1~76^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3e816adc26935cbbce5a013f85fa9c9cdb74780c;p=rspamd.git [Minor] Fix some more issues --- diff --git a/src/libserver/cfg_utils.cxx b/src/libserver/cfg_utils.cxx index f2253e051..5c5a8a24b 100644 --- a/src/libserver/cfg_utils.cxx +++ b/src/libserver/cfg_utils.cxx @@ -136,14 +136,7 @@ struct rspamd_actions_list { { std::sort(actions.begin(), actions.end(), [](const action_ptr &a1, const action_ptr &a2) -> bool { if (!isnan(a1->threshold) && !isnan(a2->threshold)) { - if (a1->threshold < a2->threshold) { - return false; - } - else if (a1->threshold > a2->threshold) { - return true; - } - - return false; + return a1->threshold < a2->threshold; } if (isnan(a1->threshold) && isnan(a2->threshold)) { @@ -923,6 +916,10 @@ rspamd_config_post_load(struct rspamd_config *cfg, auto hs_ret = rspamd_re_cache_load_hyperscan(cfg->re_cache, cfg->hs_cache_dir ? cfg->hs_cache_dir : RSPAMD_DBDIR "/", true); + + if (hs_ret == RSPAMD_HYPERSCAN_LOAD_ERROR) { + msg_debug_config("cannot load hyperscan database, disable it"); + } } if (opts & RSPAMD_CONFIG_INIT_LIBS) { @@ -1932,16 +1929,15 @@ rspamd_config_action_from_ucl(struct rspamd_config *cfg, const ucl_object_t *obj, guint priority) { - const ucl_object_t *elt; - gdouble threshold = NAN; - int flags = 0, obj_type; + auto threshold = NAN; + int flags = 0; - obj_type = ucl_object_type(obj); + auto obj_type = ucl_object_type(obj); if (obj_type == UCL_OBJECT) { obj_type = ucl_object_type(obj); - elt = ucl_object_lookup_any(obj, "score", "threshold", nullptr); + const auto *elt = ucl_object_lookup_any(obj, "score", "threshold", nullptr); if (elt) { threshold = ucl_object_todouble(elt); @@ -2063,14 +2059,18 @@ rspamd_config_set_action_score(struct rspamd_config *cfg, /* Existing element */ if (act->priority <= priority) { /* We can replace data */ - msg_info_config("action %s has been already registered with " - "priority %ud, override it with new priority: %ud, " - "old score: %.2f", - action_name, - act->priority, - priority, - act->threshold); + auto old_pri = act->priority; + auto old_thr = act->threshold; + if (rspamd_config_action_from_ucl(cfg, act, obj, priority)) { + msg_info_config("action %s has been already registered with " + "priority %ud, override it with new priority: %ud, " + "old threshold: %.2f, new threshold: %.2f", + action_name, + old_pri, + priority, + old_thr, + act->threshold); actions->sort(); } else {