[MERGED] osmocom-bb[master]: mobile: Properly close the primitive interface on reload

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sat Dec 30 20:01:20 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: mobile: Properly close the primitive interface on reload
......................................................................


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
---
M src/host/layer23/src/mobile/script_lua.c
1 file changed, 6 insertions(+), 3 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/host/layer23/src/mobile/script_lua.c b/src/host/layer23/src/mobile/script_lua.c
index 14ab58f..9b256d3 100644
--- a/src/host/layer23/src/mobile/script_lua.c
+++ b/src/host/layer23/src/mobile/script_lua.c
@@ -510,10 +510,14 @@
 
 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 @@
 	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 @@
 		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;

-- 
To view, visit https://gerrit.osmocom.org/5595
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5bb4fa9e7c5010f3ad50b258dcb14956eea8822a
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list