pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-cbc/+/38978?usp=email )
Change subject: abis: Fix reusing link->conn while it is being destroyed ......................................................................
abis: Fix reusing link->conn while it is being destroyed
Call to osmo_stream_cli_destroy() may end up triggering disconnect_cb(), and we don't want to attempt doing more stuff with that conn when that happens (we were even trying to reconnect() it...). Avoid it by marking the pointer as NULL immediatelly before calling e1inp_sign_link_destroy().
Change-Id: I56605766af974d86610d0958f4b82e6e4ff94502 --- M src/cbsp_link.c 1 file changed, 5 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-cbc refs/changes/78/38978/1
diff --git a/src/cbsp_link.c b/src/cbsp_link.c index 07fbadd..6b355df 100644 --- a/src/cbsp_link.c +++ b/src/cbsp_link.c @@ -102,6 +102,8 @@ static int cbc_cbsp_link_cli_disconnect_cb(struct osmo_stream_cli *conn) { struct cbc_cbsp_link *link = osmo_stream_cli_get_data(conn); + if (!link->conn) /* conn is being destroyed by us, we called osmo_stream_cli_destroy() */ + return 0; LOGPCC(link, LOGL_NOTICE, "Disconnected.\n"); LOGPCC(link, LOGL_NOTICE, "Reconnecting...\n"); osmo_stream_cli_reconnect(conn); @@ -364,10 +366,11 @@ return;
if (link->is_client) { - osmo_stream_cli_destroy(link->cli_conn); + struct osmo_stream_cli *cli_conn = link->cli_conn; + link->cli_conn = NULL; + osmo_stream_cli_destroy(cli_conn); if (link->peer) link->peer->link.cbsp = NULL; - link->cli_conn = NULL; if (link->fi) osmo_fsm_inst_dispatch(link->fi, CBSP_LINK_E_CMD_CLOSE, NULL); } else {