[sr-dev] git:master: modules/app_lua: Fix to lua_sr_pv_is_null()

Peter Dunkley peter.dunkley at crocodile-rcs.com
Fri Oct 14 14:59:04 CEST 2011


Module: sip-router
Branch: master
Commit: 4e4069330fd44e454c7db19b5d944dbe4ca46a39
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4e4069330fd44e454c7db19b5d944dbe4ca46a39

Author: pd <peter.dunkley at crocodile-rcs.com>
Committer: pd <peter.dunkley at crocodile-rcs.com>
Date:   Fri Oct 14 13:55:24 2011 +0100

modules/app_lua: Fix to lua_sr_pv_is_null()

- Previously this function returned an error when it could not retrieve the pv
  (for example if it did not exist).  As Lua is not a language in which you
  have to declare variables not existing is equivalent to NULL.  This function
  now treats a pv that does not exist as NULL.

---

 modules/app_lua/app_lua_sr.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/modules/app_lua/app_lua_sr.c b/modules/app_lua/app_lua_sr.c
index 1271ba2..3a2bf72 100644
--- a/modules/app_lua/app_lua_sr.c
+++ b/modules/app_lua/app_lua_sr.c
@@ -1081,8 +1081,9 @@ static int lua_sr_pv_is_null (lua_State *L)
 	memset(&val, 0, sizeof(pv_value_t));
 	if(pv_get_spec_value(env_L->msg, &pvs, &val) != 0)
 	{
-		LM_ERR("unable to get pv value for [%s]\n", pvn.s);
-		return 0;
+		LM_NOTICE("unable to get pv value for [%s]\n", pvn.s);
+		lua_pushboolean(L, 1);
+		return 1;
 	}
 	if(val.flags&PV_VAL_NULL)
 	{




More information about the sr-dev mailing list