From: Aurelien DARRAGON Date: Thu, 21 Nov 2024 15:46:26 +0000 (+0100) Subject: MINOR: hlua_fcn: add Patref:purge() method X-Git-Tag: v3.2-dev1~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fda5ca3472a91afb7169339700936dc982bd21f9;p=thirdparty%2Fhaproxy.git MINOR: hlua_fcn: add Patref:purge() method 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(). --- diff --git a/doc/lua-api/index.rst b/doc/lua-api/index.rst index c903fe1de6..db594c5cc4 100644 --- a/doc/lua-api/index.rst +++ b/doc/lua-api/index.rst @@ -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 diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c index f2336bd1e6..49219e26a7 100644 --- a/src/hlua_fcn.c +++ b/src/hlua_fcn.c @@ -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)