subscr_conn: introduce usage tokens for ref error tracking
When hunting a conn use count bug, it was very hard to figure out who's (not)
using the conn. To ease tracking down this bug and future bugs, explicitly name
what a conn is being reserved for, and track in a bit mask.
Show in the DREF logs what uses and un-uses a conn. See the test expectation
updates, which nicely show how that clarifies the state of the conn in the
logs.
On errors, log them, but don't fail hard: if one conn use/un-use fails, we
don't want to crash the entire MSC before we have to.
Change-Id: I259aa0eec41efebb4c8221275219433eafaa549b
diff --git a/src/libmsc/subscr_conn.c b/src/libmsc/subscr_conn.c
index 62b7619..0fb4f54 100644
--- a/src/libmsc/subscr_conn.c
+++ b/src/libmsc/subscr_conn.c
@@ -225,7 +225,7 @@
return;
conn->conn_fsm = NULL;
msc_subscr_conn_close(conn, cause);
- msc_subscr_conn_put(conn);
+ msc_subscr_conn_put(conn, MSC_CONN_USE_FSM);
}
int subscr_conn_fsm_timeout(struct osmo_fsm_inst *fi)
@@ -320,7 +320,7 @@
* connection, then in _osmo_fsm_inst_term() the osmo_fsm_inst_free()
* that follows the cleanup() call would run into a double free. */
fi = osmo_fsm_inst_alloc(&subscr_conn_fsm, conn->network,
- msc_subscr_conn_get(conn),
+ msc_subscr_conn_get(conn, MSC_CONN_USE_FSM),
LOGL_DEBUG, id);
if (!fi) {