BUG/MINOR: hlua_fcn: fix Patref:set() force parameter
Patref:set(key, val[, force]) takes optional "force" parameter (defaults to false) to force the entry to be created if it doesn't already exist To retrieve the value, lua_tointeger() was used in place of lua_toboolean(), and because of that force is not enabled if "true" is passed as parameter (only numbers were recognized) despite the documentation mentioning that "force" is a boolean. To fix the issue, we replace lua_tointeger by lua_toboolean. Also, the doc was updated to rename "bool" to "boolean" for the "force" parameter to stay consistent with historical naming in the file. No backport needed unless 9ee37de5c ("MINOR: hlua_fcn: add Patref:set()") is.
This commit is contained in:
parent
e5acb03137
commit
4e52438c0b
@ -3558,7 +3558,7 @@ Patref class
|
||||
|
||||
:param string key: the string used as a key
|
||||
:param string value: the string used as value
|
||||
:param bool force: create the entry if it doesn't exist (optional,
|
||||
:param boolean force: create the entry if it doesn't exist (optional,
|
||||
defaults to false)
|
||||
:returns: true on success and nil on failure (followed by an error message)
|
||||
|
||||
|
@ -2889,7 +2889,7 @@ int hlua_patref_set(lua_State *L)
|
||||
value = luaL_checkstring(L, 3);
|
||||
|
||||
if (lua_gettop(L) == 4)
|
||||
force = lua_tointeger(L, 4);
|
||||
force = lua_toboolean(L, 4);
|
||||
|
||||
HA_RWLOCK_WRLOCK(PATREF_LOCK, &ref->ptr->lock);
|
||||
if ((ref->flags & HLUA_PATREF_FL_GEN) &&
|
||||
|
Loading…
x
Reference in New Issue
Block a user