rspamd_symcache_inc_frequency(struct rspamd_symcache *_cache, struct rspamd_symcache_item *item)
{
auto *real_item = C_API_SYMCACHE_ITEM(item);
- real_item->inc_frequency();
+
+ if (real_item) {
+ real_item->inc_frequency();
+ }
}
void
it->process_deps(*this);
}
- for (auto &it: virtual_symbols) {
- it->process_deps(*this);
- }
-
/* Sorting stuff */
auto postfilters_cmp = [](const auto &it1, const auto &it2) -> int {
if (it1->priority > it2->priority) {
if (virtual_id_from >= 0) {
- g_assert (virtual_id_from < (gint) virtual_symbols.size());
+ g_assert (virtual_id_from < (gint) items_by_id.size());
/* We need that for settings id propagation */
- const auto &vsource = virtual_symbols[virtual_id_from];
+ const auto &vsource = items_by_id[virtual_id_from];
g_assert (vsource.get() != nullptr);
vsource->deps.emplace_back(cache_item_ptr{nullptr},
std::string(to),
if (item->is_virtual()) {
if (!(item->flags & SYMBOL_TYPE_GHOST)) {
- item->resolve_parent(*this);
auto *parent = const_cast<cache_item *>(item->get_parent(*this));
+ if (parent == nullptr) {
+ item->resolve_parent(*this);
+ parent = const_cast<cache_item *>(item->get_parent(*this));
+ }
+
if (::fabs(parent->st->weight) < ::fabs(item->st->weight)) {
parent->st->weight = item->st->weight;
}
return nullptr;
}
+auto cache_item::get_parent_mut(const symcache &cache) -> cache_item *
+{
+ if (is_virtual()) {
+ auto &virtual_sp = std::get<virtual_item>(specific);
+
+ return virtual_sp.get_parent_mut(cache);
+ }
+
+ return nullptr;
+}
+
auto cache_item::process_deps(const symcache &cache) -> void
{
/* Allow logging macros to work */
}
else {
/* Create a reverse dep */
- dit->rdeps.emplace_back(getptr(), dep.sym, id, -1);
- dep.item = dit->getptr();
- dep.id = dit->id;
+ if (is_virtual()) {
+ auto *parent = get_parent_mut(cache);
+
+ if (parent) {
+ dit->rdeps.emplace_back(parent->getptr(), dep.sym, parent->id, -1);
+ dep.item = dit->getptr();
+ dep.id = dit->id;
- msg_debug_cache ("add dependency from %d on %d", id,
- dit->id);
+ msg_debug_cache ("added reverse dependency from %d on %d", id,
+ dit->id);
+ }
+ }
}
}
}
return cache.get_item_by_id(parent_id, false);
}
+auto virtual_item::get_parent_mut(const symcache &cache) -> cache_item *
+{
+ if (parent) {
+ return parent.get();
+ }
+
+ return const_cast<cache_item *>(cache.get_item_by_id(parent_id, false));
+}
+
auto virtual_item::resolve_parent(const symcache &cache) -> bool
{
if (parent) {
}
auto get_parent(const symcache &cache) const -> const cache_item *;
+ auto get_parent_mut(const symcache &cache) -> cache_item *;
auto resolve_parent(const symcache &cache) -> bool;
};
}
auto get_parent(const symcache &cache) const -> const cache_item *;
+ auto get_parent_mut(const symcache &cache) -> cache_item *;
auto resolve_parent(const symcache &cache) -> bool;
cbd->event = rspamd_session_add_event (task->s,
rspamd_symcache_delayed_item_fin, cbd,
"symcache");
+ cbd->runtime = this;
/*
* If no event could be added, then we are already in the destruction