diff --git a/modules/app_lua/app_lua_api.c b/modules/app_lua/app_lua_api.c index ee3a0f1084b..5a603df7828 100644 --- a/modules/app_lua/app_lua_api.c +++ b/modules/app_lua/app_lua_api.c @@ -621,8 +621,8 @@ int app_lua_runstring(struct sip_msg *msg, char *script) /** * */ -int app_lua_run(struct sip_msg *msg, char *func, char *p1, char *p2, - char *p3) +int app_lua_run_ex(sip_msg_t *msg, char *func, char *p1, char *p2, + char *p3, int emode) { int n; int ret; @@ -648,13 +648,17 @@ int app_lua_run(struct sip_msg *msg, char *func, char *p1, char *p2, lua_getglobal(_sr_L_env.LL, func); if(!lua_isfunction(_sr_L_env.LL, -1)) { - LM_ERR("no such function [%s] in lua scripts\n", func); - LM_ERR("top stack type [%d - %s]\n", + if(emode) { + LM_ERR("no such function [%s] in lua scripts\n", func); + LM_ERR("top stack type [%d - %s]\n", lua_type(_sr_L_env.LL, -1), lua_typename(_sr_L_env.LL,lua_type(_sr_L_env.LL, -1))); - txt = (char*)lua_tostring(_sr_L_env.LL, -1); - LM_ERR("error from Lua: %s\n", (txt)?txt:"unknown"); - return -1; + txt = (char*)lua_tostring(_sr_L_env.LL, -1); + LM_ERR("error from Lua: %s\n", (txt)?txt:"unknown"); + return -1; + } else { + return 1; + } } n = 0; if(p1!=NULL) @@ -687,6 +691,15 @@ int app_lua_run(struct sip_msg *msg, char *func, char *p1, char *p2, return 1; } +/** + * + */ +int app_lua_run(sip_msg_t *msg, char *func, char *p1, char *p2, + char *p3) +{ + return app_lua_run_ex(msg, func, p1, p2, p3, 1); +} + void app_lua_dump_stack(lua_State *L) { int i; diff --git a/modules/app_lua/app_lua_api.h b/modules/app_lua/app_lua_api.h index dea48b065d1..4182184aaed 100644 --- a/modules/app_lua/app_lua_api.h +++ b/modules/app_lua/app_lua_api.h @@ -72,8 +72,10 @@ int sr_lua_reload_module(unsigned int reload); int app_lua_dostring(struct sip_msg *msg, char *script); int app_lua_dofile(struct sip_msg *msg, char *script); int app_lua_runstring(struct sip_msg *msg, char *script); -int app_lua_run(struct sip_msg *msg, char *func, char *p1, char *p2, +int app_lua_run(sip_msg_t *msg, char *func, char *p1, char *p2, char *p3); +int app_lua_run_ex(sip_msg_t *msg, char *func, char *p1, char *p2, + char *p3, int emode); #define SRLUA_FALSE 0 #define SRLUA_TRUE 1 diff --git a/modules/app_lua/app_lua_mod.c b/modules/app_lua/app_lua_mod.c index 693d2c8d846..11134ea6c77 100644 --- a/modules/app_lua/app_lua_mod.c +++ b/modules/app_lua/app_lua_mod.c @@ -112,9 +112,9 @@ int sr_kemi_config_engine_lua(sip_msg_t *msg, int rtype, str *rname) int ret; if(rtype==REQUEST_ROUTE) { - ret = app_lua_run(msg, "ksr_request_route", NULL, NULL, NULL); + ret = app_lua_run_ex(msg, "ksr_request_route", NULL, NULL, NULL, 1); } else if(rtype==CORE_ONREPLY_ROUTE) { - ret = app_lua_run(msg, "ksr_reply_route", NULL, NULL, NULL); + ret = app_lua_run_ex(msg, "ksr_reply_route", NULL, NULL, NULL, 0); } else { if(rname!=NULL) { LM_ERR("route type %d with name [%.*s] not implemented\n",