From: Vsevolod Stakhov Date: Tue, 8 Feb 2011 18:22:58 +0000 (+0300) Subject: Call lua function properly. X-Git-Tag: 0.3.7~53 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=93a1584882133dc81d46fa8e15943fcab6e8ce3f;p=rspamd.git Call lua function properly. --- diff --git a/src/lua/lua_cfg_file.c b/src/lua/lua_cfg_file.c index a7c48aedf..fca0d0772 100644 --- a/src/lua/lua_cfg_file.c +++ b/src/lua/lua_cfg_file.c @@ -125,7 +125,7 @@ lua_process_element (struct config_file *cfg, const gchar *name, struct module_o opt->lua_type = LUA_VAR_STRING; break; case LUA_TFUNCTION: - opt->actual_data = memory_pool_strdup (cfg->cfg_pool, lua_tostring (L, idx)); + opt->actual_data = memory_pool_strdup (cfg->cfg_pool, name); opt->lua_type = LUA_VAR_FUNCTION; break; case LUA_TNIL: @@ -230,12 +230,17 @@ lua_handle_param (struct worker_task *task, gchar *mname, gchar *optname, enum l /* First check function in config table */ lua_getglobal (L, "config"); if (lua_istable (L, -1)) { - lua_pushstring (L, opt->actual_data); + lua_pushstring (L, mname); lua_gettable (L, -2); if (lua_isnil (L, -1)) { /* Try to get global variable */ lua_getglobal (L, opt->actual_data); } + else { + /* Call local function in table */ + lua_pushstring (L, opt->actual_data); + lua_gettable (L, -2); + } } else { /* Try to get global variable */