pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/32232 )
Change subject: bts: Simplify lifecycle of BTS inside bts_list ......................................................................
bts: Simplify lifecycle of BTS inside bts_list
Add the BTS object to the BTS list as the first thing after it is created, this way it's always attached and hence simply always detach it during object free.
Change-Id: Ica4fe2a4be0c85b10702011e978be03bf970b0c8 --- M src/common/bts.c 1 file changed, 21 insertions(+), 12 deletions(-)
Approvals: laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved osmith: Looks good to me, but someone else must approve Jenkins Builder: Verified
diff --git a/src/common/bts.c b/src/common/bts.c index 23e4456..af66311 100644 --- a/src/common/bts.c +++ b/src/common/bts.c @@ -226,6 +226,8 @@ }
bts_osmux_release(bts); + + llist_del(&bts->list); return 0; }
@@ -240,6 +242,9 @@
talloc_set_destructor(bts, gsm_bts_talloc_destructor);
+ /* add to list of BTSs */ + llist_add_tail(&bts->list, &bts_gsmnet.bts_list); + bts->nr = bts_num; bts->num_trx = 0; INIT_LLIST_HEAD(&bts->trx_list); @@ -323,19 +328,14 @@ static int initialized = 0; void *tall_rtp_ctx;
- /* add to list of BTSs */ - llist_add_tail(&bts->list, &bts_gsmnet.bts_list); - bts->band = GSM_BAND_1800;
INIT_LLIST_HEAD(&bts->agch_queue.queue); bts->agch_queue.length = 0;
bts->ctrs = rate_ctr_group_alloc(bts, &bts_ctrg_desc, bts->nr); - if (!bts->ctrs) { - llist_del(&bts->list); + if (!bts->ctrs) return -1; - }
/* enable management with default levels, * raise threshold to GSM_BTS_AGCH_QUEUE_THRESH_LEVEL_DISABLE to @@ -394,10 +394,8 @@
/* Osmux */ rc = bts_osmux_init(bts); - if (rc < 0) { - llist_del(&bts->list); + if (rc < 0) return rc; - }
/* features implemented in 'common', available for all models, * order alphabetically */ @@ -409,10 +407,8 @@ osmo_bts_set_feature(bts->features, BTS_FEAT_PAGING_COORDINATION);
rc = bts_model_init(bts); - if (rc < 0) { - llist_del(&bts->list); + if (rc < 0) return rc; - }
/* TRX0 was allocated early during gsm_bts_alloc, not later through VTY */ bts_model_trx_init(bts->c0);