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.orgHarald Welte has submitted this change and it was merged.
Change subject: VIRT-PHY: Properly destroy l1_model_ms after disconnect
......................................................................
VIRT-PHY: Properly destroy l1_model_ms after disconnect
If a MS disconnects, we need to clean up all related state
Change-Id: Ib7adef61150b5a4338483019e4dd75d7279d1f5d
---
M src/host/virt_phy/include/virtphy/l1ctl_sap.h
M src/host/virt_phy/include/virtphy/l1ctl_sock.h
M src/host/virt_phy/src/l1ctl_sap.c
M src/host/virt_phy/src/l1ctl_sock.c
M src/host/virt_phy/src/virt_l1_model.c
M src/host/virt_phy/src/virt_prim_pm.c
M src/host/virt_phy/src/virtphy.c
7 files changed, 33 insertions(+), 1 deletion(-)
Approvals:
Harald Welte: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/src/host/virt_phy/include/virtphy/l1ctl_sap.h b/src/host/virt_phy/include/virtphy/l1ctl_sap.h
index 5903a02..94174da 100644
--- a/src/host/virt_phy/include/virtphy/l1ctl_sap.h
+++ b/src/host/virt_phy/include/virtphy/l1ctl_sap.h
@@ -27,7 +27,9 @@
void l1ctl_sap_init(struct l1_model_ms *model);
+void l1ctl_sap_exit(struct l1_model_ms *model);
void prim_pm_init(struct l1_model_ms *model);
+void prim_pm_exit(struct l1_model_ms *model);
void l1ctl_sap_tx_to_l23_inst(struct l1_model_ms *model, struct msgb *msg);
void l1ctl_sap_rx_from_l23_inst_cb(struct l1ctl_sock_client *lsc, struct msgb *msg);
void l1ctl_sap_rx_from_l23(struct msgb *msg);
diff --git a/src/host/virt_phy/include/virtphy/l1ctl_sock.h b/src/host/virt_phy/include/virtphy/l1ctl_sock.h
index 82ee5ca..2c98fa5 100644
--- a/src/host/virt_phy/include/virtphy/l1ctl_sock.h
+++ b/src/host/virt_phy/include/virtphy/l1ctl_sock.h
@@ -28,6 +28,8 @@
void (*recv_cb)(struct l1ctl_sock_client *lsc, struct msgb *msg); /* Callback function called for incoming data from l2 app. */
/* Callback function called for new client after accept() */
int (*accept_cb)(struct l1ctl_sock_client *lsc);
+ /* Callback function called when client disappeared */
+ void (*close_cb)(struct l1ctl_sock_client *lsc);
};
/**
@@ -37,6 +39,7 @@
void *ctx,
void (*recv_cb)(struct l1ctl_sock_client *lsc, struct msgb *msg),
int (*accept_cb)(struct l1ctl_sock_client *lsc),
+ void (*close_cb)(struct l1ctl_sock_client *lsc),
char *path);
/**
diff --git a/src/host/virt_phy/src/l1ctl_sap.c b/src/host/virt_phy/src/l1ctl_sap.c
index c7c8e3e..d4b33f1 100644
--- a/src/host/virt_phy/src/l1ctl_sap.c
+++ b/src/host/virt_phy/src/l1ctl_sap.c
@@ -58,6 +58,12 @@
prim_pm_init(model);
}
+void l1ctl_sap_exit(struct l1_model_ms *model)
+{
+ virt_l1_sched_stop(model);
+ prim_pm_exit(model);
+}
+
/**
* @brief L1CTL handler called for received messages from L23.
*
diff --git a/src/host/virt_phy/src/l1ctl_sock.c b/src/host/virt_phy/src/l1ctl_sock.c
index 00f25a6..bf28895 100644
--- a/src/host/virt_phy/src/l1ctl_sock.c
+++ b/src/host/virt_phy/src/l1ctl_sock.c
@@ -47,6 +47,9 @@
static void l1ctl_client_destroy(struct l1ctl_sock_client *lsc)
{
+ struct l1ctl_sock_inst *lsi = lsc->l1ctl_sock;
+ if (lsi->close_cb)
+ lsi->close_cb(lsc);
osmo_fd_close(&lsc->ofd);
llist_del(&lsc->list);
talloc_free(lsc);
@@ -149,6 +152,7 @@
void *ctx,
void (*recv_cb)(struct l1ctl_sock_client *lsc, struct msgb *msg),
int (*accept_cb)(struct l1ctl_sock_client *lsc),
+ void (*close_cb)(struct l1ctl_sock_client *lsc),
char *path)
{
struct l1ctl_sock_inst *lsi;
@@ -172,6 +176,7 @@
lsi->recv_cb = recv_cb;
lsi->accept_cb = accept_cb;
+ lsi->close_cb = close_cb;
lsi->l1ctl_sock_path = path;
INIT_LLIST_HEAD(&lsi->clients);
diff --git a/src/host/virt_phy/src/virt_l1_model.c b/src/host/virt_phy/src/virt_l1_model.c
index 14676b0..6a9fa99 100644
--- a/src/host/virt_phy/src/virt_l1_model.c
+++ b/src/host/virt_phy/src/virt_l1_model.c
@@ -46,5 +46,6 @@
void l1_model_ms_destroy(struct l1_model_ms *model)
{
LOGPMS(DMAIN, LOGL_INFO, model, "destryed\n");
+ l1ctl_sap_exit(model);
talloc_free(model);
}
diff --git a/src/host/virt_phy/src/virt_prim_pm.c b/src/host/virt_phy/src/virt_prim_pm.c
index 1cd3c03..4637013 100644
--- a/src/host/virt_phy/src/virt_prim_pm.c
+++ b/src/host/virt_phy/src/virt_prim_pm.c
@@ -138,3 +138,12 @@
l1s->pm.meas.arfcn_sig_lev_timers[i].data = &l1s->pm.meas.arfcn_sig_lev_dbm[i];
}
}
+
+void prim_pm_exit(struct l1_model_ms *model)
+{
+ struct l1_state_ms *l1s = &model->state;
+ int i;
+
+ for (i = 0; i < 1024; ++i)
+ osmo_timer_del(&l1s->pm.meas.arfcn_sig_lev_timers[i]);
+}
diff --git a/src/host/virt_phy/src/virtphy.c b/src/host/virt_phy/src/virtphy.c
index b6f4f0c..23811c2 100644
--- a/src/host/virt_phy/src/virtphy.c
+++ b/src/host/virt_phy/src/virtphy.c
@@ -162,6 +162,12 @@
return 0;
}
+static void l1ctl_close_cb(struct l1ctl_sock_client *lsc)
+{
+ struct l1_model_ms *ms = lsc->priv;
+ l1_model_ms_destroy(ms);
+}
+
int main(int argc, char *argv[])
{
/* init loginfo */
@@ -175,7 +181,7 @@
gsmtapl1_rx_from_virt_um_inst_cb);
g_vphy.l1ctl_sock = l1ctl_sock_init(NULL, l1ctl_sap_rx_from_l23_inst_cb,
- l1ctl_accept_cb, l1ctl_sock_path);
+ l1ctl_accept_cb, l1ctl_close_cb, l1ctl_sock_path);
g_vphy.virt_um->priv = g_vphy.l1ctl_sock;
LOGP(DVIRPHY, LOGL_INFO,
--
To view, visit https://gerrit.osmocom.org/3291
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib7adef61150b5a4338483019e4dd75d7279d1f5d
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder