diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2021-09-22 19:40:15 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2021-09-23 14:07:53 +0200 |
commit | bc6d35f52d4d3abd650afb05475ad5a818737fe2 (patch) | |
tree | 1f21fd879d57e7346459b88a43f3872dbb9e0bc2 | |
parent | 127e8fc4166dc34e17dd0768028f3f00a5fa639c (diff) |
abis: Fix line leaked & recreated upon every reconnect
Previous code creating a new line was really a workaroudn to have it
working while previous lines were being stacked internally inside
libosmo-abis.
Let's handle reference counts for the line properly and erase +
re-create it every time.
Recent patches to libosmo-abis fixed a crash happening when refcount
being 0 and destroying the object (object was not removed from a global
llist).
Depends: libosmo-abis Change-Id I1314d6b917ecb622994507475eb894e649a1a2ad
Change-Id: Ic37ae5bf657247e8cce99182c40d9adf890a5e41
-rw-r--r-- | include/osmo-bts/abis.h | 2 | ||||
-rw-r--r-- | src/common/abis.c | 22 |
2 files changed, 12 insertions, 12 deletions
diff --git a/include/osmo-bts/abis.h b/include/osmo-bts/abis.h index 40707cd1..d5cf6348 100644 --- a/include/osmo-bts/abis.h +++ b/include/osmo-bts/abis.h @@ -8,7 +8,7 @@ enum abis_link_fsm_event { ABIS_LINK_EV_SIGN_LINK_OML_UP, - ABIS_LINK_EV_SIGN_LINK_DOWN, + ABIS_LINK_EV_SIGN_LINK_DOWN, /* data: struct e1inp_line* of link going down */ ABIS_LINK_EV_VTY_RM_ADDR, /* data: struct bsc_oml_host* being removed */ }; diff --git a/src/common/abis.c b/src/common/abis.c index 93635c2f..b7345766 100644 --- a/src/common/abis.c +++ b/src/common/abis.c @@ -81,7 +81,6 @@ struct abis_link_fsm_priv { struct bsc_oml_host *current_bsc; struct gsm_bts *bts; char *model_name; - int line_ctr; }; static void reset_oml_link(struct gsm_bts *bts) @@ -156,15 +155,7 @@ static void abis_link_connecting_onenter(struct osmo_fsm_inst *fi, uint32_t prev bts_dev_info.unit_name = bts->description; bts_dev_info.location2 = priv->model_name; - line = e1inp_line_find(priv->line_ctr); - if (line) { - e1inp_line_get2(line, __FILE__); /* We want a new reference for returned line */ - } else - line = e1inp_line_create(priv->line_ctr, "ipa"); /* already comes with a reference */ - - /* The abis connection may fail and we may have to try again with a different BSC (if configured). The next - * attempt must happen on a different line. */ - priv->line_ctr++; + line = e1inp_line_create(0, "ipa"); /* already comes with a reference "ctor" */ if (!line) { osmo_fsm_inst_state_chg(fi, ABIS_LINK_ST_FAILED, 0, 0); @@ -186,13 +177,17 @@ static void abis_link_connecting(struct osmo_fsm_inst *fi, uint32_t event, void { struct abis_link_fsm_priv *priv = fi->priv; struct gsm_bts *bts = priv->bts; + struct e1inp_line *line; switch (event) { case ABIS_LINK_EV_SIGN_LINK_OML_UP: osmo_fsm_inst_state_chg(fi, ABIS_LINK_ST_CONNECTED, 0, 0); break; case ABIS_LINK_EV_SIGN_LINK_DOWN: + line = (struct e1inp_line *)data; reset_oml_link(bts); + /* Drop reference obtained through e1inp_line_create() to get rid of the line object: */ + e1inp_line_put2(line, "ctor"); osmo_fsm_inst_state_chg(fi, ABIS_LINK_ST_WAIT_RECONNECT, OML_RETRY_TIMER, 0); break; default: @@ -210,6 +205,7 @@ static void abis_link_connected(struct osmo_fsm_inst *fi, uint32_t event, void * struct abis_link_fsm_priv *priv = fi->priv; struct gsm_bts *bts = priv->bts; struct gsm_bts_trx *trx; + struct e1inp_line *line = (struct e1inp_line *)data; OSMO_ASSERT(event == ABIS_LINK_EV_SIGN_LINK_DOWN); /* First remove the OML signalling link */ @@ -232,6 +228,10 @@ static void abis_link_connected(struct osmo_fsm_inst *fi, uint32_t event, void * * that TRX only. But libosmo-abis expects us to drop the entire * line when something goes wrong... */ } + + /* Drop reference obtained through e1inp_line_create() to get rid of the line object: */ + e1inp_line_put2(line, "ctor"); + bts_model_abis_close(bts); osmo_fsm_inst_state_chg(fi, ABIS_LINK_ST_WAIT_RECONNECT, OML_RETRY_TIMER, 0); } @@ -395,7 +395,7 @@ static struct e1inp_sign_link *sign_link_up(void *unit, struct e1inp_line *line, static void sign_link_down(struct e1inp_line *line) { LOGPIL(line, DABIS, LOGL_ERROR, "Signalling link down\n"); - osmo_fsm_inst_dispatch(g_bts->abis_link_fi, ABIS_LINK_EV_SIGN_LINK_DOWN, NULL); + osmo_fsm_inst_dispatch(g_bts->abis_link_fi, ABIS_LINK_EV_SIGN_LINK_DOWN, line); } |