aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-06-19 16:12:10 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2024-06-19 16:12:10 +0100
commit229362aa191fd7d4981338ec39c0b9a947206195 (patch)
treee84913d387b4a36854852ef61e8db032d3a5598a
parent5273dcc8aa35eaaeebcd144929d05d8d4b84d357 (diff)
downloadrspamd-229362aa191fd7d4981338ec39c0b9a947206195.tar.gz
rspamd-229362aa191fd7d4981338ec39c0b9a947206195.zip
[Minor] Use internal flags
-rw-r--r--src/libserver/symcache/symcache_impl.cxx2
-rw-r--r--src/libserver/symcache/symcache_item.cxx4
-rw-r--r--src/libserver/symcache/symcache_item.hxx17
3 files changed, 13 insertions, 10 deletions
diff --git a/src/libserver/symcache/symcache_impl.cxx b/src/libserver/symcache/symcache_impl.cxx
index 56d3602ae..4ea087024 100644
--- a/src/libserver/symcache/symcache_impl.cxx
+++ b/src/libserver/symcache/symcache_impl.cxx
@@ -978,7 +978,7 @@ auto symcache::validate(bool strict) -> bool
auto item = get_item_by_name_mut((const char *) k, false);
if (item) {
- item->enabled = FALSE;
+ item->internal_flags &= ~cache_item::bit_enabled;
}
}
}
diff --git a/src/libserver/symcache/symcache_item.cxx b/src/libserver/symcache/symcache_item.cxx
index 0b5de9f3a..490a87880 100644
--- a/src/libserver/symcache/symcache_item.cxx
+++ b/src/libserver/symcache/symcache_item.cxx
@@ -334,11 +334,11 @@ auto cache_item::is_allowed(struct rspamd_task *task, bool exec_only) const -> b
}
/* Static checks */
- if (!enabled ||
+ if (!(internal_flags & cache_item::bit_enabled) ||
(RSPAMD_TASK_IS_EMPTY(task) && !(flags & SYMBOL_TYPE_EMPTY)) ||
(flags & SYMBOL_TYPE_MIME_ONLY && !RSPAMD_TASK_IS_MIME(task))) {
- if (!enabled) {
+ if (!(internal_flags & cache_item::bit_enabled)) {
msg_debug_cache_task("skipping %s of %s as it is permanently disabled",
what, symbol.c_str());
diff --git a/src/libserver/symcache/symcache_item.hxx b/src/libserver/symcache/symcache_item.hxx
index e446eb9ba..5f4056e4b 100644
--- a/src/libserver/symcache/symcache_item.hxx
+++ b/src/libserver/symcache/symcache_item.hxx
@@ -214,15 +214,18 @@ struct cache_item : std::enable_shared_from_this<cache_item> {
struct rspamd_symcache_item_stat *st = nullptr;
struct rspamd_counter_data *cd = nullptr;
+ std::string symbol;
+
/* Unique id - counter */
int id;
std::uint64_t last_count = 0;
- std::string symbol;
symcache_item_type type;
int flags;
- /* Condition of execution */
- bool enabled = true;
+ static constexpr const auto bit_enabled = 0b0001;
+ static constexpr const auto bit_sync = 0b0010;
+ static constexpr const auto bit_slow = 0b0100;
+ int internal_flags = bit_enabled;
/* Priority */
int priority = 0;
@@ -514,8 +517,8 @@ private:
void *user_data,
symcache_item_type _type,
int _flags)
- : id(_id),
- symbol(std::move(name)),
+ : symbol(std::move(name)),
+ id(_id),
type(_type),
flags(_flags),
priority(_priority),
@@ -543,8 +546,8 @@ private:
int parent,
symcache_item_type _type,
int _flags)
- : id(_id),
- symbol(std::move(name)),
+ : symbol(std::move(name)),
+ id(_id),
type(_type),
flags(_flags),
specific(virtual_item{parent})