From: Vsevolod Stakhov Date: Sat, 7 May 2022 12:09:42 +0000 (+0100) Subject: [Minor] Fix conditions operations X-Git-Tag: 3.3~273 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=47cf9c8082000be8b63fbeb4c6d35c7b2bd05af5;p=rspamd.git [Minor] Fix conditions operations --- diff --git a/src/libserver/symcache/symcache_impl.cxx b/src/libserver/symcache/symcache_impl.cxx index 25918ce1d..fb274e080 100644 --- a/src/libserver/symcache/symcache_impl.cxx +++ b/src/libserver/symcache/symcache_impl.cxx @@ -35,10 +35,12 @@ auto symcache::init() -> bool reload_time = cfg->cache_reload_time; if (cfg->cache_filename != nullptr) { + msg_debug_cache("loading symcache saved data from %s", cfg->cache_filename); res = load_items(); } /* Deal with the delayed dependencies */ + msg_debug_cache("resolving delayed dependencies: %d in list", (int)delayed_deps->size()); for (const auto &delayed_dep: *delayed_deps) { auto virt_item = get_item_by_name(delayed_dep.from, false); auto real_item = get_item_by_name(delayed_dep.from, true); @@ -64,6 +66,7 @@ auto symcache::init() -> bool /* Deal with the delayed conditions */ + msg_debug_cache("resolving delayed conditions: %d in list", (int)delayed_conditions->size()); for (const auto &delayed_cond: *delayed_conditions) { auto it = get_item_by_name_mut(delayed_cond.sym, true); @@ -80,10 +83,13 @@ auto symcache::init() -> bool delayed_cond.sym.c_str()); g_abort(); } + + msg_debug_cache("added a condition to the symbol %s", it->symbol.c_str()); } } delayed_conditions.reset(); + msg_debug_cache("process dependencies"); for (auto &it: items_by_id) { it->process_deps(*this); } @@ -110,7 +116,7 @@ auto symcache::init() -> bool return 1; }; - + msg_debug_cache("sorting stuff"); std::stable_sort(std::begin(connfilters), std::end(connfilters), prefilters_cmp); std::stable_sort(std::begin(prefilters), std::end(prefilters), prefilters_cmp); std::stable_sort(std::begin(postfilters), std::end(postfilters), postfilters_cmp); @@ -120,6 +126,7 @@ auto symcache::init() -> bool /* Connect metric symbols with symcache symbols */ if (cfg->symbols) { + msg_debug_cache("connect metrics"); g_hash_table_foreach(cfg->symbols, symcache::metric_connect_cb, (void *) this); diff --git a/src/libserver/symcache/symcache_item.cxx b/src/libserver/symcache/symcache_item.cxx index e918d5b2c..70c1921bb 100644 --- a/src/libserver/symcache/symcache_item.cxx +++ b/src/libserver/symcache/symcache_item.cxx @@ -472,14 +472,11 @@ auto item_condition::check(std::string_view sym_name, struct rspamd_task *task) if (cb != -1 && L != nullptr) { auto ret = false; - lua_rawgeti(L, LUA_REGISTRYINDEX, cb); - lua_pushcfunction (L, &rspamd_lua_traceback); auto err_idx = lua_gettop(L); - auto **ptask = (struct rspamd_task **) lua_newuserdata(L, sizeof(struct rspamd_task *)); - rspamd_lua_setclass(L, "rspamd{task}", -1); - *ptask = task; + lua_rawgeti(L, LUA_REGISTRYINDEX, cb); + rspamd_lua_task_push(L, task); if (lua_pcall(L, 1, 1, err_idx) != 0) { msg_info_task("call to condition for %s failed: %s", diff --git a/src/libserver/symcache/symcache_item.hxx b/src/libserver/symcache/symcache_item.hxx index 1d0cd7e35..89c00ded5 100644 --- a/src/libserver/symcache/symcache_item.hxx +++ b/src/libserver/symcache/symcache_item.hxx @@ -85,11 +85,21 @@ auto item_type_from_c(enum rspamd_symbol_type type) -> tl::expected bool; };