[PATCH] osmo-hlr[master]: more robust usage of osmo_timer API for osmo-hlr luop timer

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

Stefan Sperling gerrit-no-reply at lists.osmocom.org
Thu Mar 29 16:17:26 UTC 2018


Review at  https://gerrit.osmocom.org/7587

more robust usage of osmo_timer API for osmo-hlr luop timer

Use osmo_timer_setup() to set up the luop timer, instead of
settting the timer up manually.

Delete the timer before the luop is freed to prevent a potential
crash in case the timer is already armed and the function call
chain leading up to lu_op_free() does not cancel the timer.

Found while studying code to prepare work on issue OS#2785.

This change has been tested with 'make check' and TTCN3 HLR tests.

Related: OS#2785
Change-Id: I1a7596675b2d94217895f0f3d3f67b86ef123c2e
---
M src/luop.c
1 file changed, 5 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/87/7587/1

diff --git a/src/luop.c b/src/luop.c
index 4ef4ea3..02c41d0 100644
--- a/src/luop.c
+++ b/src/luop.c
@@ -108,8 +108,7 @@
 	luop = talloc_zero(srv, struct lu_operation);
 	OSMO_ASSERT(luop);
 	luop->gsup_server = srv;
-	luop->timer.cb = lu_op_timer_cb;
-	luop->timer.data = luop;
+	osmo_timer_setup(&luop->timer, lu_op_timer_cb, luop);
 
 	return luop;
 }
@@ -119,6 +118,10 @@
 	/* Only attempt to remove when it was ever added to a list. */
 	if (luop->list.next)
 		llist_del(&luop->list);
+
+	/* Delete timer just in case it is still pending. */
+	osmo_timer_del(&luop->timer);
+
 	talloc_free(luop);
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a7596675b2d94217895f0f3d3f67b86ef123c2e
Gerrit-PatchSet: 1
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling <ssperling at sysmocom.de>



More information about the gerrit-log mailing list