]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Try to fix stats for the virtual symbols
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 6 Aug 2022 22:47:35 +0000 (23:47 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 6 Aug 2022 22:47:35 +0000 (23:47 +0100)
src/libmime/scan_result.c
src/libserver/rspamd_symcache.h
src/libserver/symcache/symcache_c.cxx
src/libserver/symcache/symcache_item.hxx

index 0b9844b08856ee4e4b66b268fe23d42e7f6879f3..33cac5f70c359eccffb13c3872a8209cc0e90eb8 100644 (file)
@@ -586,7 +586,8 @@ rspamd_task_insert_result_full (struct rspamd_task *task,
                                /* Process cache item */
                                if (symbol_result && task->cfg->cache && symbol_result->sym && symbol_result->nshots == 1) {
                                        rspamd_symcache_inc_frequency (task->cfg->cache,
-                                                       symbol_result->sym->cache_item);
+                                                       symbol_result->sym->cache_item,
+                                                       symbol_result->sym->name);
                                }
                        }
                        else if (new_symbol) {
@@ -610,7 +611,8 @@ rspamd_task_insert_result_full (struct rspamd_task *task,
                        /* Process cache item */
                        if (symbol_result && task->cfg->cache && symbol_result->sym && symbol_result->nshots == 1) {
                                rspamd_symcache_inc_frequency (task->cfg->cache,
-                                               symbol_result->sym->cache_item);
+                                               symbol_result->sym->cache_item,
+                                               symbol_result->sym->name);
                        }
                }
        }
index 0510cb1dc27b3906dc06d030d8b868eeb5a1f4f3..a7258143243087b6962d841dbad2ac0d71f83bde 100644 (file)
@@ -231,7 +231,8 @@ void* rspamd_symcache_start_refresh (struct rspamd_symcache *cache,
  * @param symbol
  */
 void rspamd_symcache_inc_frequency (struct rspamd_symcache *_cache,
-                                                                       struct rspamd_symcache_item *item);
+                                                                       struct rspamd_symcache_item *item,
+                                                                       const gchar *sym_name);
 
 /**
  * Add delayed dependency that is resolved on cache post-load routine
index d4ae88e672b0fd4759282e7b7476a1e8032ab05d..76cac67b60116d8892644e80b6862afacead51ac 100644 (file)
@@ -214,12 +214,13 @@ 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);
 
        if (real_item) {
-               real_item->inc_frequency();
+               real_item->inc_frequency(sym_name);
        }
 }
 
index 94e3dc57def3b28c699619cdcb97ef8a091fa6c3..8387cf5231407a415a8e742a6f3de821a56c9425 100644 (file)
@@ -343,8 +343,17 @@ public:
        /**
         * Increase frequency for a symbol
         */
-       auto inc_frequency() -> void {
+       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);
+                               }
+                       }
+               }
        }
 
        /**