From 17b0d83a1f1a153b21b198f101294c8ed9e172ac Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sat, 19 Oct 2013 17:37:48 +0200 Subject: pdch: Move enable/disable into the PDCH code When a PDCH is disabled all resources should be freed. This is currently not possible as the PDCH does not know where it belongs to. On top of that the list (and other resources) should be properly initialized on construction so that disable() is idempotent and does not check if it was disabled. During the re-factoring I noticed that during a sysmobts re-start some resources are not freed. I left a warning in the code to resolve this issue later. --- src/bts.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src/bts.cpp') diff --git a/src/bts.cpp b/src/bts.cpp index 29cd3e5d..ca012883 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -20,6 +20,13 @@ #include #include +#include + +#include + +extern "C" { + #include +} #include @@ -53,3 +60,40 @@ void BTS::set_current_frame_number(int fn) m_cur_fn = fn; m_pollController.expireTimedout(m_cur_fn); } + +void gprs_rlcmac_pdch::enable() +{ + /* TODO: Check if there are still allocated resources.. */ + INIT_LLIST_HEAD(&paging_list); + m_is_enabled = 1; +} + +void gprs_rlcmac_pdch::disable() +{ + /* TODO.. kick free_resources once we know the TRX/TS we are on */ + m_is_enabled = 0; +} + +void gprs_rlcmac_pdch::free_resources(uint8_t trx, uint8_t ts) +{ + struct gprs_rlcmac_paging *pag; + struct gprs_rlcmac_sba *sba, *sba2; + + /* we are not enabled. there should be no resources */ + if (!is_enabled()) + return; + + /* kick all TBF on slot */ + gprs_rlcmac_tbf::free_all(this); + + /* flush all pending paging messages */ + while ((pag = gprs_rlcmac_dequeue_paging(this))) + talloc_free(pag); + + llist_for_each_entry_safe(sba, sba2, &gprs_rlcmac_sbas, list) { + if (sba->trx == trx && sba->ts == ts) { + llist_del(&sba->list); + talloc_free(sba); + } + } +} -- cgit v1.2.3