fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmocom-bb/+/28861 )
Change subject: trxcon: rework TRXC/TRXD cleanup logic, add trx_fsm_cleanup_cb()
......................................................................
trxcon: rework TRXC/TRXD cleanup logic, add trx_fsm_cleanup_cb()
Change-Id: Ic599b51067cb5a331fca521a5b46ab0a2804e499
Related: OS#5599
---
M src/host/trxcon/src/trx_if.c
1 file changed, 19 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/61/28861/1
diff --git a/src/host/trxcon/src/trx_if.c b/src/host/trxcon/src/trx_if.c
index af879c1..5e4e696 100644
--- a/src/host/trxcon/src/trx_if.c
+++ b/src/host/trxcon/src/trx_if.c
@@ -46,6 +46,9 @@
#define S(x) (1 << (x))
+static void trx_fsm_cleanup_cb(struct osmo_fsm_inst *fi,
+ enum osmo_fsm_term_cause cause);
+
static struct value_string trx_evt_names[] = {
{ 0, NULL } /* no events? */
};
@@ -82,6 +85,7 @@
.num_states = ARRAY_SIZE(trx_fsm_states),
.log_subsys = DTRXC,
.event_names = trx_evt_names,
+ .cleanup = &trx_fsm_cleanup_cb,
};
static int trx_udp_open(void *priv, struct osmo_fd *ofd, const char *host_local,
@@ -738,7 +742,11 @@
if (rc < 0)
goto udp_error;
+ /* Reparent trx_instance from trxcon to trx->fi */
+ talloc_reparent(trxcon, trx->fi, trx);
+
trx->trxcon = trxcon;
+ trx->fi->priv = trx;
return trx;
@@ -768,13 +776,22 @@
void trx_if_close(struct trx_instance *trx)
{
+ if (trx == NULL || trx->fi == NULL)
+ return;
+ osmo_fsm_inst_term(trx->fi, OSMO_FSM_TERM_REQUEST, NULL);
+}
+
+static void trx_fsm_cleanup_cb(struct osmo_fsm_inst *fi,
+ enum osmo_fsm_term_cause cause)
+{
static const char cmd_poweroff[] = "CMD POWEROFF";
+ struct trx_instance *trx = fi->priv;
/* May be unallocated due to init error */
if (!trx)
return;
- LOGPFSML(trx->fi, LOGL_NOTICE, "Shutdown transceiver interface\n");
+ LOGPFSML(fi, LOGL_NOTICE, "Shutdown transceiver interface\n");
/* Abort TRXC response timer (if pending) */
osmo_timer_del(&trx->trx_ctrl_timer);
@@ -791,7 +808,7 @@
trx_udp_close(&trx->trx_ofd_data);
/* Free memory */
- osmo_fsm_inst_free(trx->fi);
+ trx->fi->priv = NULL;
talloc_free(trx);
}
--
To view, visit
https://gerrit.osmocom.org/c/osmocom-bb/+/28861
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Ic599b51067cb5a331fca521a5b46ab0a2804e499
Gerrit-Change-Number: 28861
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange