]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Some symcache neats
authorVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 5 May 2022 21:11:36 +0000 (22:11 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 5 May 2022 21:11:36 +0000 (22:11 +0100)
src/libserver/symcache/symcache_impl.cxx
src/libserver/symcache/symcache_runtime.cxx

index ab1b41fc425059e49a59526fcc3ee6e4b776a49b..8da0cbecb86a854d3347779a0fd2a2a0dbee5cbc 100644 (file)
@@ -1027,24 +1027,21 @@ symcache::process_settings_elt(struct rspamd_config_settings_elt *elt) -> void
 
                        if (item != nullptr) {
                                if (item->is_virtual()) {
-                                       if (!(item->flags & SYMBOL_TYPE_GHOST)) {
-                                               auto *parent = get_item_by_name_mut(sym, true);
-
-                                               if (parent) {
-                                                       if (elt->symbols_disabled &&
-                                                               ucl_object_lookup(elt->symbols_disabled, parent->symbol.data())) {
-                                                               msg_err_cache ("conflict in %s: cannot enable disabled symbol %s, "
-                                                                                          "wanted to enable symbol %s",
-                                                                               elt->name, parent->symbol.data(), sym);
-                                                               continue;
-                                                       }
-
-                                                       parent->exec_only_ids.add_id(id, static_pool);
-                                                       msg_debug_cache ("allow just execution of symbol %s for settings %ud (%s)",
-                                                                       parent->symbol.data(), id, elt->name);
+                                       auto *parent = get_item_by_name_mut(sym, true);
+
+                                       if (parent) {
+                                               if (elt->symbols_disabled &&
+                                                       ucl_object_lookup(elt->symbols_disabled, parent->symbol.data())) {
+                                                       msg_err_cache ("conflict in %s: cannot enable disabled symbol %s, "
+                                                                                  "wanted to enable symbol %s",
+                                                                       elt->name, parent->symbol.data(), sym);
+                                                       continue;
                                                }
+
+                                               parent->exec_only_ids.add_id(id, static_pool);
+                                               msg_debug_cache ("allow just execution of symbol %s for settings %ud (%s)",
+                                                               parent->symbol.data(), id, elt->name);
                                        }
-                                       /* Ignore ghosts */
                                }
 
                                item->allowed_ids.add_id(id, static_pool);
index 7ee8b9cd9ce7c7ff8e865c54ef12fab4883c4156..1e334230b423fbbc6529f5c497a65a35f0e6d524 100644 (file)
@@ -119,6 +119,7 @@ symcache_runtime::process_settings(struct rspamd_task *task, const symcache &cac
        const auto *enabled = ucl_object_lookup(task->settings, "symbols_enabled");
 
        if (enabled) {
+               msg_debug_cache_task("disable all symbols as `symbols_enabled` is found");
                /* Disable all symbols but selected */
                disable_all_symbols(SYMBOL_TYPE_EXPLICIT_DISABLE);
                already_disabled = true;
@@ -159,9 +160,8 @@ symcache_runtime::process_settings(struct rspamd_task *task, const symcache &cac
 
 auto symcache_runtime::disable_all_symbols(int skip_mask) -> void
 {
-       for (auto i = 0; i < order->size(); i++) {
+       for (auto [i, item] : rspamd::enumerate(order->d)) {
                auto *dyn_item = &dynamic_items[i];
-               const auto &item = order->d[i];
 
                if (!(item->get_flags() & skip_mask)) {
                        dyn_item->finished = true;