]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Remove useless check
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 13 May 2022 19:38:14 +0000 (20:38 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 13 May 2022 19:38:14 +0000 (20:38 +0100)
src/libserver/symcache/symcache_runtime.cxx

index b9706c62af7c2654d39a1c99b4dff731a2238844..e5f93eb0dbca64f325b411e5f8a6d657f741594f 100644 (file)
@@ -155,7 +155,7 @@ symcache_runtime::process_settings(struct rspamd_task *task, const symcache &cac
 
 auto symcache_runtime::disable_all_symbols(int skip_mask) -> void
 {
-       for (auto [i, item] : rspamd::enumerate(order->d)) {
+       for (auto[i, item]: rspamd::enumerate(order->d)) {
                auto *dyn_item = &dynamic_items[i];
 
                if (!(item->get_flags() & skip_mask)) {
@@ -379,7 +379,7 @@ symcache_runtime::process_filters(struct rspamd_task *task, symcache &cache, int
 {
        auto all_done = true;
 
-       for (const auto [idx, item] : rspamd::enumerate(order->d)) {
+       for (const auto[idx, item]: rspamd::enumerate(order->d)) {
                /* Exclude all non filters */
                if (item->type != symcache_item_type::FILTER) {
                        /*
@@ -544,67 +544,64 @@ auto symcache_runtime::check_item_deps(struct rspamd_task *task, symcache &cache
 
                auto ret = true;
 
-               if (!item->deps.empty()) {
+               for (const auto &dep: item->deps) {
+                       if (!dep.item) {
+                               /* Assume invalid deps as done */
+                               msg_debug_cache_task("symbol %d(%s) has invalid dependencies on %d(%s)",
+                                               item->id, item->symbol.c_str(), dep.id, dep.sym.c_str());
+                               continue;
+                       }
 
-                       for (const auto &dep: item->deps) {
-                               if (!dep.item) {
-                                       /* Assume invalid deps as done */
-                                       msg_debug_cache_task("symbol %d(%s) has invalid dependencies on %d(%s)",
-                                                       item->id, item->symbol.c_str(), dep.id, dep.sym.c_str());
-                                       continue;
-                               }
+                       auto *dep_dyn_item = get_dynamic_item(dep.item->id);
 
-                               auto *dep_dyn_item = get_dynamic_item(dep.item->id);
-
-                               if (!dep_dyn_item->finished) {
-                                       if (!dep_dyn_item->started) {
-                                               /* Not started */
-                                               if (!check_only) {
-                                                       if (!rec_functor(recursion + 1,
-                                                                       dep.item.get(),
-                                                                       dep_dyn_item,
-                                                                       rec_functor)) {
-
-                                                               ret = false;
-                                                               msg_debug_cache_task("delayed dependency %d(%s) for "
-                                                                                                        "symbol %d(%s)",
-                                                                               dep.id, dep.sym.c_str(), item->id, item->symbol.c_str());
-                                                       }
-                                                       else if (!process_symbol(task, cache, dep.item.get(), dep_dyn_item)) {
-                                                               /* Now started, but has events pending */
-                                                               ret = false;
-                                                               msg_debug_cache_task("started check of %d(%s) symbol "
-                                                                                                        "as dep for "
-                                                                                                        "%d(%s)",
-                                                                               dep.id, dep.sym.c_str(), item->id, item->symbol.c_str());
-                                                       }
-                                                       else {
-                                                               msg_debug_cache_task("dependency %d(%s) for symbol %d(%s) is "
-                                                                                                        "already processed",
-                                                                               dep.id, dep.sym.c_str(), item->id, item->symbol.c_str());
-                                                       }
+                       if (!dep_dyn_item->finished) {
+                               if (!dep_dyn_item->started) {
+                                       /* Not started */
+                                       if (!check_only) {
+                                               if (!rec_functor(recursion + 1,
+                                                               dep.item.get(),
+                                                               dep_dyn_item,
+                                                               rec_functor)) {
+
+                                                       ret = false;
+                                                       msg_debug_cache_task("delayed dependency %d(%s) for "
+                                                                                                "symbol %d(%s)",
+                                                                       dep.id, dep.sym.c_str(), item->id, item->symbol.c_str());
+                                               }
+                                               else if (!process_symbol(task, cache, dep.item.get(), dep_dyn_item)) {
+                                                       /* Now started, but has events pending */
+                                                       ret = false;
+                                                       msg_debug_cache_task("started check of %d(%s) symbol "
+                                                                                                "as dep for "
+                                                                                                "%d(%s)",
+                                                                       dep.id, dep.sym.c_str(), item->id, item->symbol.c_str());
                                                }
                                                else {
-                                                       msg_debug_cache_task("dependency %d(%s) for symbol %d(%s) "
-                                                                                                "cannot be started now",
+                                                       msg_debug_cache_task("dependency %d(%s) for symbol %d(%s) is "
+                                                                                                "already processed",
                                                                        dep.id, dep.sym.c_str(), item->id, item->symbol.c_str());
-                                                       ret = false;
                                                }
                                        }
                                        else {
-                                               /* Started but not finished */
-                                               msg_debug_cache_task("dependency %d(%s) for symbol %d(%s) is "
-                                                                                        "still executing",
+                                               msg_debug_cache_task("dependency %d(%s) for symbol %d(%s) "
+                                                                                        "cannot be started now",
                                                                dep.id, dep.sym.c_str(), item->id, item->symbol.c_str());
                                                ret = false;
                                        }
                                }
                                else {
-                                       msg_debug_cache_task("dependency %d(%s) for symbol %d(%s) is already "
-                                                                                "checked",
+                                       /* Started but not finished */
+                                       msg_debug_cache_task("dependency %d(%s) for symbol %d(%s) is "
+                                                                                "still executing",
                                                        dep.id, dep.sym.c_str(), item->id, item->symbol.c_str());
+                                       ret = false;
                                }
                        }
+                       else {
+                               msg_debug_cache_task("dependency %d(%s) for symbol %d(%s) is already "
+                                                                        "checked",
+                                               dep.id, dep.sym.c_str(), item->id, item->symbol.c_str());
+                       }
                }
 
                return ret;
@@ -795,7 +792,7 @@ symcache_runtime::get_item_by_dynamic_item(cache_dynamic_item *dyn_item) const -
                return order->d[idx].get();
        }
 
-       msg_err("internal error: invalid index to get: %d", (int)idx);
+       msg_err("internal error: invalid index to get: %d", (int) idx);
 
        return nullptr;
 }