]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Use internal flags
authorVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 19 Jun 2024 15:12:10 +0000 (16:12 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 19 Jun 2024 15:12:10 +0000 (16:12 +0100)
src/libserver/symcache/symcache_impl.cxx
src/libserver/symcache/symcache_item.cxx
src/libserver/symcache/symcache_item.hxx

index 56d3602aec1cc1f683cff02afbe5421cf13299bf..4ea08702484e6dd3fd6165487bdc1a34e1f5d48b 100644 (file)
@@ -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;
                        }
                }
        }
index 0b5de9f3a89b53f8190319fc0522d1e4ca5e5b24..490a878806067a4ce7340a07ef31592b997a56e7 100644 (file)
@@ -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());
 
index e446eb9ba8a58def2e0d5924af083c9e0158ef77..5f4056e4b6a00f8eb57bf747dedbbeff7de8cb05 100644 (file)
@@ -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})