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);
/* 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);
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);
}
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);
/* 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);
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",
struct item_condition {
private:
- lua_State *L;
- int cb;
+ lua_State *L = nullptr;
+ int cb = -1;
public:
- item_condition(lua_State *_L, int _cb) : L(_L), cb(_cb) {}
- virtual ~item_condition();
+ explicit item_condition(lua_State *L_, int cb_) noexcept : L(L_), cb(cb_) {}
+ item_condition(item_condition &&other) noexcept {
+ *this = std::move(other);
+ }
+ /* Make it move only */
+ item_condition(const item_condition &) = delete;
+ item_condition& operator=(item_condition &&other) noexcept {
+ std::swap(other.L, L);
+ std::swap(other.cb, cb);
+ return *this;
+ }
+ ~item_condition();
auto check(std::string_view sym_name, struct rspamd_task *task) const -> bool;
};