diff options
| author | Donald Lee <dlqs@gmx.com> | 2021-08-10 07:07:06 +0800 |
|---|---|---|
| committer | Donald Lee <dlqs@gmx.com> | 2021-08-10 07:35:32 +0800 |
| commit | 2ed598ba6bdbd8b6b6c6e9a091faad15306d19de (patch) | |
| tree | 270667e3a4625d96541e63e4bfed232dee963b4f /lib/frrscript.c | |
| parent | 80bfe93670461bfc868c6252e2f15bd44586cd4e (diff) | |
lib: Enable consecutive frrscript_call
Previous:
- frrscript_load: push Lua function onto stack
- frrscript_call: calls Lua function
Now:
- frrscript_load: checks Lua function
- frrscript_call: pushes and calls Lua function (first clear the stack)
So now we just need one frrscript_load for consecutive frrscript_call.
frrscript_call does not recompile or reload the script file, it just
keys it from the global Lua table (where it should already be).
Signed-off-by: Donald Lee <dlqs@gmx.com>
Diffstat (limited to 'lib/frrscript.c')
| -rw-r--r-- | lib/frrscript.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/frrscript.c b/lib/frrscript.c index c9fc938997..0e0d3c030c 100644 --- a/lib/frrscript.c +++ b/lib/frrscript.c @@ -288,13 +288,16 @@ int frrscript_load(struct frrscript *fs, const char *function_name, goto fail; } - /* Push the Lua function we want */ + /* To check the Lua function, we get it from the global table */ lua_getglobal(L, function_name); if (lua_isfunction(L, lua_gettop(L)) == 0) { zlog_err("frrscript: loaded script '%s.lua' but %s not found", script_name, function_name); goto fail; } + /* Then pop the function (frrscript_call will push it when it needs it) + */ + lua_pop(L, 1); if (load_cb && (*load_cb)(fs) != 0) { zlog_err( |
