]> source.dussan.org Git - rspamd.git/commitdiff
Call lua function properly.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Tue, 8 Feb 2011 18:22:58 +0000 (21:22 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Tue, 8 Feb 2011 18:22:58 +0000 (21:22 +0300)
src/lua/lua_cfg_file.c

index a7c48aedf27b44f11f91eb3fe0384ec05da5b5ae..fca0d0772fed98cb86233c0d9617f955803af203 100644 (file)
@@ -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 */