Change in osmocom-bb[master]: Forget about the callback after use and cancellation

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/.

Holger Freyther gerrit-no-reply at lists.osmocom.org
Sun Aug 19 21:36:31 UTC 2018


Holger Freyther has uploaded this change for review. ( https://gerrit.osmocom.org/10536


Change subject: Forget about the callback after use and cancellation
......................................................................

Forget about the callback after use and cancellation

Don't try to unref something else after we have given up our
spot in the table.

Change-Id: I4e8db297e816d3d07a46147d5d3bdc0e8fae6c9a
---
M src/host/layer23/src/mobile/script_lua.c
1 file changed, 5 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/36/10536/1

diff --git a/src/host/layer23/src/mobile/script_lua.c b/src/host/layer23/src/mobile/script_lua.c
index 4cfe55a..088aab3 100644
--- a/src/host/layer23/src/mobile/script_lua.c
+++ b/src/host/layer23/src/mobile/script_lua.c
@@ -136,6 +136,7 @@
 
 	lua_rawgeti(L, LUA_REGISTRYINDEX, timer->cb_ref);
 	luaL_unref(L, LUA_REGISTRYINDEX, timer->cb_ref);
+	timer->cb_ref = LUA_NOREF;
 
 	err = lua_pcall(L, 0, 0, 0);
 	if (err) {
@@ -276,6 +277,10 @@
 
 	luaL_argcheck(L, lua_isuserdata(L, -1), 1, "No userdata");
 	timer = lua_touserdata(L, -1);
+	if (timer->cb_ref != LUA_NOREF) {
+		luaL_unref(L, LUA_REGISTRYINDEX, timer->cb_ref);
+		timer->cb_ref = LUA_NOREF;
+	}
 
 	prim = mobile_prim_alloc(PRIM_MOB_TIMER_CANCEL, PRIM_OP_REQUEST);
 	prim->u.timer.timer_id = (intptr_t) timer;

-- 
To view, visit https://gerrit.osmocom.org/10536
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4e8db297e816d3d07a46147d5d3bdc0e8fae6c9a
Gerrit-Change-Number: 10536
Gerrit-PatchSet: 1
Gerrit-Owner: Holger Freyther <holger at freyther.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180819/5ee0ed04/attachment.htm>


More information about the gerrit-log mailing list