Module: kamailio
Branch: master
Commit: 92ac41c1e770077d39516fc049358b3c3897d590
URL: 
https://github.com/kamailio/kamailio/commit/92ac41c1e770077d39516fc049358b3c3897d590

Author: Victor Seva <linuxman...@torreviejawireless.org>
Committer: Victor Seva <linuxman...@torreviejawireless.org>
Date: 2024-04-15T10:50:26+02:00

app_lua_sr: support second str for cfgutils lock

---

Modified: src/modules/app_lua_sr/app_lua_sr_exp.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/92ac41c1e770077d39516fc049358b3c3897d590.diff
Patch: 
https://github.com/kamailio/kamailio/commit/92ac41c1e770077d39516fc049358b3c3897d590.patch

---

diff --git a/src/modules/app_lua_sr/app_lua_sr_exp.c 
b/src/modules/app_lua_sr/app_lua_sr_exp.c
index 522f0cfb87a..80a4cb69042 100644
--- a/src/modules/app_lua_sr/app_lua_sr_exp.c
+++ b/src/modules/app_lua_sr/app_lua_sr_exp.c
@@ -2783,20 +2783,29 @@ static const luaL_Reg _sr_sanity_Map[] = {
 static int lua_sr_cfgutils_lock(lua_State *L)
 {
        int ret;
-       str lkey;
+       str lkey, lkey2;
 
        if(!(_sr_lua_exp_reg_mods & SR_LUA_EXP_MOD_CFGUTILS)) {
                LM_WARN("weird: cfgutils function executed but module not "
                                "registered\n");
                return app_lua_return_error(L);
        }
-       if(lua_gettop(L) != 1) {
+       ret = lua_gettop(L);
+       if(ret < 1 || ret > 3) {
                LM_WARN("invalid number of parameters from Lua\n");
                return app_lua_return_error(L);
        }
+       if(ret > 1) {
+               lkey2.s = (char *)lua_tostring(L, -1);
+               lkey2.len = strlen(lkey2.s);
+       }
        lkey.s = (char *)lua_tostring(L, -1);
        lkey.len = strlen(lkey.s);
-       ret = _lua_cfgutilsb.mlock(&lkey);
+       if(ret > 1) {
+               ret = _lua_cfgutilsb.mlock(&lkey, &lkey2);
+       } else {
+               ret = _lua_cfgutilsb.mlock(&lkey, NULL);
+       }
 
        return app_lua_return_int(L, ret);
 }
@@ -2808,20 +2817,29 @@ static int lua_sr_cfgutils_lock(lua_State *L)
 static int lua_sr_cfgutils_unlock(lua_State *L)
 {
        int ret;
-       str lkey;
+       str lkey, lkey2;
 
        if(!(_sr_lua_exp_reg_mods & SR_LUA_EXP_MOD_CFGUTILS)) {
                LM_WARN("weird: cfgutils function executed but module not "
                                "registered\n");
                return app_lua_return_error(L);
        }
-       if(lua_gettop(L) != 1) {
+       ret = lua_gettop(L);
+       if(ret < 1 || ret > 3) {
                LM_WARN("invalid number of parameters from Lua\n");
                return app_lua_return_error(L);
        }
+       if(ret > 1) {
+               lkey2.s = (char *)lua_tostring(L, -1);
+               lkey2.len = strlen(lkey2.s);
+       }
        lkey.s = (char *)lua_tostring(L, -1);
        lkey.len = strlen(lkey.s);
-       ret = _lua_cfgutilsb.munlock(&lkey);
+       if(ret > 1) {
+               ret = _lua_cfgutilsb.munlock(&lkey, &lkey2);
+       } else {
+               ret = _lua_cfgutilsb.munlock(&lkey, NULL);
+       }
 
        return app_lua_return_int(L, ret);
 }

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org

Reply via email to