]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: hlua_fcn: add Patref:purge() method
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 21 Nov 2024 15:46:26 +0000 (16:46 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Fri, 29 Nov 2024 06:23:20 +0000 (07:23 +0100)
It is a special Lua Patref method: it bypasses the commit/prepare logic
and purges the whole pattern reference items pointed to by Patref Lua
object (all versions, not just the current one). It doesn't have a cli
equivalent: it leverages pat_ref_purge_range().

doc/lua-api/index.rst
src/hlua_fcn.c

index c903fe1de6f2b59bd61048fa9d6632ef9b8609d3..db594c5cc4bab0c60a19ae582b37998f5e1d5567 100644 (file)
@@ -3456,6 +3456,11 @@ Patref class
   :returns: true if the pattern reference is used to handle maps instead
    of acl, false otherwise.
 
+.. js:function:: Patref.purge(ref)
+
+  Completely prune all pattern reference entries pointed to by Patref object.
+  This special operation doesn't require committing.
+
 .. js:function:: Patref.prepare(ref)
 
   Create a new empty version for Patref Object. It can be used to manipulate
index f2336bd1e675c917a8e59c33284d041b50c1ff09..49219e26a789916651b19045b978b466692ffa20 100644 (file)
@@ -2705,6 +2705,18 @@ int hlua_patref_prepare(lua_State *L)
        return 0;
 }
 
+int hlua_patref_purge(lua_State *L)
+{
+       struct hlua_patref *ref;
+
+       ref = hlua_checkudata(L, 1, class_patref_ref);
+       BUG_ON(!ref);
+
+       lua_pushinteger(L, 0); // from
+       lua_pushinteger(L, ~0); // to
+       return _hlua_patref_clear(L, LUA_OK, 0);
+}
+
 void hlua_fcn_new_patref(lua_State *L, struct pat_ref *ref)
 {
        struct hlua_patref *_ref;
@@ -2734,6 +2746,7 @@ void hlua_fcn_new_patref(lua_State *L, struct pat_ref *ref)
        hlua_class_function(L, "is_map", hlua_patref_is_map);
        hlua_class_function(L, "prepare", hlua_patref_prepare);
        hlua_class_function(L, "commit", hlua_patref_commit);
+       hlua_class_function(L, "purge", hlua_patref_purge);
 }
 
 int hlua_patref_gc(lua_State *L)