]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Implement adding deps and remove an old deprecated method
authorVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 20 Apr 2022 18:57:54 +0000 (19:57 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 20 Apr 2022 18:57:54 +0000 (19:57 +0100)
src/libserver/rspamd_symcache.h
src/libserver/symcache/symcache_c.cxx
src/libserver/symcache/symcache_internal.hxx
src/lua/lua_config.c

index 62a4c8714d86b464a4f4baf7f4eda48e528fbff5..0ef76c832d2a1d1f3ded73e443ba6929c73330f4 100644 (file)
@@ -222,17 +222,6 @@ void* rspamd_symcache_start_refresh (struct rspamd_symcache *cache,
 void rspamd_symcache_inc_frequency (struct rspamd_symcache *cache,
                                                                        struct rspamd_symcache_item *item);
 
-/**
- * Add dependency relation between two symbols identified by id (source) and
- * a symbolic name (destination). Destination could be virtual or real symbol.
- * Callback destinations are not yet supported.
- * @param id_from source symbol
- * @param to destination name
- */
-void rspamd_symcache_add_dependency (struct rspamd_symcache *cache,
-                                                                        gint id_from, const gchar *to,
-                                                                        gint virtual_id_from);
-
 /**
  * Add delayed dependency that is resolved on cache post-load routine
  * @param cache
index 29aa1d91d5ad8ade7bce340fc36848104667c39a..5432c22f41458ae632c35f5f88ef6f02a8bd7807 100644 (file)
@@ -182,4 +182,12 @@ rspamd_symcache_inc_frequency(struct rspamd_symcache *_cache, struct rspamd_symc
 {
        auto *real_item = C_API_SYMCACHE_ITEM(item);
        real_item->inc_frequency();
+}
+
+void
+rspamd_symcache_add_delayed_dependency (struct rspamd_symcache *cache,
+                                                                               const gchar *from, const gchar *to)
+{
+       auto *real_cache = C_API_SYMCACHE(cache);
+       real_cache->add_delayed_dependency(from, to);
 }
\ No newline at end of file
index 576a0bfd42b102d008210885a97909e4dc296452..1bfd2f881b5037bd63574a42bc5649b230a7ad56 100644 (file)
@@ -95,6 +95,8 @@ using order_generation_ptr = std::shared_ptr<order_generation>;
 struct delayed_cache_dependency {
        std::string from;
        std::string to;
+
+       delayed_cache_dependency(std::string_view _from, std::string_view _to) : from(_from), to(_to) {}
 };
 
 struct delayed_cache_condition {
@@ -209,6 +211,19 @@ public:
         */
        auto add_dependency(int id_from, std::string_view to, int virtual_id_from) -> void;
 
+       /**
+        * Add a delayed dependency between symbols that will be resolved on the init stage
+        * @param from
+        * @param to
+        */
+       auto add_delayed_dependency(std::string_view from, std::string_view to) -> void {
+               if (!delayed_deps) {
+                       delayed_deps = std::make_unique<std::vector<delayed_cache_dependency>>();
+               }
+
+               delayed_deps->emplace_back(from, to);
+       }
+
        /**
         * Initialises the symbols cache, must be called after all symbols are added
         * and the config file is loaded
index 607b9717490440e2cc57450d65c72fc5298c7c91..8c19671f1d1aa222c7fcb4785e0d5cdeaf22a805 100644 (file)
@@ -2323,14 +2323,8 @@ lua_config_register_dependency (lua_State * L)
                child_id = luaL_checknumber (L, 2);
                parent = luaL_checkstring (L, 3);
 
-               msg_warn_config ("calling for obsolete method to register deps for symbol %d->%s",
+               return luaL_error(L,"calling for obsolete method to register deps for symbol %d->%s",
                                child_id, parent);
-
-               if (child_id > 0 && parent != NULL) {
-
-                       rspamd_symcache_add_dependency (cfg->cache, child_id, parent,
-                                       -1);
-               }
        }
        else {
                child = luaL_checkstring (L,2);