From: Vsevolod Stakhov Date: Sat, 15 Jan 2022 12:24:25 +0000 (+0000) Subject: [Minor] Deal with unknown weight more carefully to avoid special meaning of 0 X-Git-Tag: 3.2~98 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b3073d94bdcfabc37aeb27678c996a554c9f1df7;p=rspamd.git [Minor] Deal with unknown weight more carefully to avoid special meaning of 0 The special unknown weight must be NAN not 0.0 --- diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index 67ceb5df8..44cdbc84f 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -171,6 +171,7 @@ rspamd_config_new (enum rspamd_config_init_flags flags) cfg->dns_retransmits = 5; /* 16 sockets per DNS server */ cfg->dns_io_per_server = 16; + cfg->unknown_weight = NAN; /* Add all internal actions to keep compatibility */ for (int i = METRIC_ACTION_REJECT; i < METRIC_ACTION_MAX; i ++) { diff --git a/src/libserver/rspamd_symcache.c b/src/libserver/rspamd_symcache.c index d1fb68672..4335ada68 100644 --- a/src/libserver/rspamd_symcache.c +++ b/src/libserver/rspamd_symcache.c @@ -1438,7 +1438,7 @@ rspamd_symcache_validate_cb (gpointer k, gpointer v, gpointer ud) (SYMBOL_TYPE_NORMAL|SYMBOL_TYPE_VIRTUAL|SYMBOL_TYPE_COMPOSITE|SYMBOL_TYPE_CLASSIFIER)) && g_hash_table_lookup (cfg->symbols, item->symbol) == NULL) { - if (cfg->unknown_weight != 0) { + if (!isnan(cfg->unknown_weight)) { skipped = FALSE; item->st->weight = cfg->unknown_weight; @@ -1448,7 +1448,8 @@ rspamd_symcache_validate_cb (gpointer k, gpointer v, gpointer ud) s->weight_ptr = &item->st->weight; g_hash_table_insert (cfg->symbols, item->symbol, s); - msg_info_cache ("adding unknown symbol %s", item->symbol); + msg_info_cache ("adding unknown symbol %s with weight: %.2f", + item->symbol, cfg->unknown_weight); ghost = FALSE; } else {