aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2022-08-07 20:30:14 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2022-08-07 20:30:14 +0100
commitbe01ab406474d4251cb22b11f218d26264db9750 (patch)
treed3a33cb9ec60c3b0c232a2b3dce3dcc611ba7067 /src/libserver
parent160c6ad5167ed20fbfd33b5ab413ca48cc4ed1f2 (diff)
downloadrspamd-be01ab406474d4251cb22b11f218d26264db9750.tar.gz
rspamd-be01ab406474d4251cb22b11f218d26264db9750.zip
[Minor] One more effort to select a proper item to change
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/symcache/symcache_c.cxx5
-rw-r--r--src/libserver/symcache/symcache_item.hxx27
2 files changed, 22 insertions, 10 deletions
diff --git a/src/libserver/symcache/symcache_c.cxx b/src/libserver/symcache/symcache_c.cxx
index 83d6b9842..71e0057ee 100644
--- a/src/libserver/symcache/symcache_c.cxx
+++ b/src/libserver/symcache/symcache_c.cxx
@@ -214,13 +214,14 @@ rspamd_symcache_start_refresh(struct rspamd_symcache *cache,
}
void
-rspamd_symcache_inc_frequency(struct rspamd_symcache *_cache, struct rspamd_symcache_item *item,
+rspamd_symcache_inc_frequency(struct rspamd_symcache *cache, struct rspamd_symcache_item *item,
const char *sym_name)
{
auto *real_item = C_API_SYMCACHE_ITEM(item);
+ auto *real_cache = C_API_SYMCACHE(cache);
if (real_item) {
- real_item->inc_frequency(sym_name);
+ real_item->inc_frequency(sym_name, *real_cache);
}
}
diff --git a/src/libserver/symcache/symcache_item.hxx b/src/libserver/symcache/symcache_item.hxx
index 8387cf523..034a26e2c 100644
--- a/src/libserver/symcache/symcache_item.hxx
+++ b/src/libserver/symcache/symcache_item.hxx
@@ -343,16 +343,27 @@ public:
/**
* Increase frequency for a symbol
*/
- auto inc_frequency(const char *sym_name) -> void {
- g_atomic_int_inc(&st->hits);
-
- if (sym_name && symbol != sym_name && !is_virtual()) {
- /* Likely a callback symbol with some virtual symbol that needs to be adjusted */
- for (const auto &cld : get_children().value().get()) {
- if (cld->get_name() == sym_name) {
- cld->inc_frequency(sym_name);
+ auto inc_frequency(const char *sym_name, symcache &cache) -> void {
+ if (sym_name && symbol != sym_name) {
+ if (is_filter()) {
+ /* Likely a callback symbol with some virtual symbol that needs to be adjusted */
+ for (const auto &cld: get_children().value().get()) {
+ if (cld->get_name() == sym_name) {
+ cld->inc_frequency(sym_name);
+ }
}
}
+ else {
+ /* Name not equal to symbol name, so we need to find the proper name */
+ auto *another_item = cache.get_item_by_name_mut(sym_name, false);
+ if (another_item != nullptr) {
+ another_item->inc_frequency(sym_name, cache);
+ }
+ }
+ }
+ else {
+ /* Symbol and sym name are the same */
+ g_atomic_int_inc(&st->hits);
}
}