diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2017-12-27 10:50:14 +0800 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2017-12-27 10:50:14 +0800 |
commit | ceb0875f1a2c90de826450f1de127450b62bcd9b (patch) | |
tree | 4e26c77dcf9e38c24277b77927971ab9a98db7d4 /src/host/layer23/src/mobile/script_lua.c | |
parent | a8130aba91247e07df83d2612f14d58d9a45eaa7 (diff) |
mobile: Properly close the primitive interface on reload
When reloading a script go through script_lua_close. Get the
primitive first. Then destruct the lua environment which will
lead to GC (e.g. cancellation of timers) and then delete the
primitive code.
Change-Id: I5bb4fa9e7c5010f3ad50b258dcb14956eea8822a
Diffstat (limited to 'src/host/layer23/src/mobile/script_lua.c')
-rw-r--r-- | src/host/layer23/src/mobile/script_lua.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/host/layer23/src/mobile/script_lua.c b/src/host/layer23/src/mobile/script_lua.c index 14ab58fd..9b256d3a 100644 --- a/src/host/layer23/src/mobile/script_lua.c +++ b/src/host/layer23/src/mobile/script_lua.c @@ -510,10 +510,14 @@ static void *talloc_lua_alloc(void *ctx, void *ptr, size_t osize, size_t nsize) int script_lua_close(struct osmocom_ms *ms) { + struct mobile_prim_intf *intf; + if (!ms->lua_state) return 0; + intf = get_primitive(ms->lua_state); lua_close(ms->lua_state); + mobile_prim_intf_free(intf); ms->lua_state = NULL; return 0; } @@ -523,8 +527,7 @@ int script_lua_load(struct vty *vty, struct osmocom_ms *ms, const char *filename struct mobile_prim_intf *intf; int err; - if (ms->lua_state) - lua_close(ms->lua_state); + script_lua_close(ms); ms->lua_state = lua_newstate(talloc_lua_alloc, ms); if (!ms->lua_state) return -1; @@ -550,7 +553,7 @@ int script_lua_load(struct vty *vty, struct osmocom_ms *ms, const char *filename vty_out(vty, "%% LUA execute error: %s%s", lua_tostring(ms->lua_state, -1), VTY_NEWLINE); lua_pop(ms->lua_state, 1); - return 3; + return -3; } return 0; |