Change in osmo-bsc[master]: introduce osmo_use_count for bsc_subscr

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

neels gerrit-no-reply at lists.osmocom.org
Wed Oct 7 12:38:12 UTC 2020


neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/20351 )

Change subject: introduce osmo_use_count for bsc_subscr
......................................................................

introduce osmo_use_count for bsc_subscr

During LCS development, I'm getting use count bugs and would like to see use
token strings to figure it out.

Change-Id: I29bf60059d4cf7bb99a00753e6cdc149baf95f94
---
M include/osmocom/bsc/bsc_subscr_conn_fsm.h
M include/osmocom/bsc/bsc_subscriber.h
M include/osmocom/bsc/paging.h
M src/osmo-bsc/bsc_subscr_conn_fsm.c
M src/osmo-bsc/bsc_subscriber.c
M src/osmo-bsc/bsc_vty.c
M src/osmo-bsc/gsm_08_08.c
M src/osmo-bsc/osmo_bsc_bssap.c
M src/osmo-bsc/paging.c
M tests/handover/handover_test.c
M tests/subscr/bsc_subscr_test.c
M tests/subscr/bsc_subscr_test.err
12 files changed, 155 insertions(+), 106 deletions(-)

Approvals:
  Jenkins Builder: Verified
  neels: Looks good to me, approved
  laforge: Looks good to me, but someone else must approve
  pespin: Looks good to me, but someone else must approve



diff --git a/include/osmocom/bsc/bsc_subscr_conn_fsm.h b/include/osmocom/bsc/bsc_subscr_conn_fsm.h
index 354c5ee..9b6398a 100644
--- a/include/osmocom/bsc/bsc_subscr_conn_fsm.h
+++ b/include/osmocom/bsc/bsc_subscr_conn_fsm.h
@@ -3,6 +3,8 @@
 #include <osmocom/gsm/protocol/gsm_04_08.h>
 #include <osmocom/core/fsm.h>
 
+#define BSUB_USE_CONN "conn"
+
 enum gscon_fsm_event {
 	/* local SCCP stack tells us incoming conn from MSC */
 	GSCON_EV_A_CONN_IND,
diff --git a/include/osmocom/bsc/bsc_subscriber.h b/include/osmocom/bsc/bsc_subscriber.h
index a602a9e..6fffafd 100644
--- a/include/osmocom/bsc/bsc_subscriber.h
+++ b/include/osmocom/bsc/bsc_subscriber.h
@@ -5,6 +5,7 @@
 #include <stdint.h>
 
 #include <osmocom/core/linuxlist.h>
+#include <osmocom/core/use_count.h>
 #include <osmocom/gsm/protocol/gsm_23_003.h>
 #include <osmocom/gsm/gsm48.h>
 
@@ -12,7 +13,7 @@
 
 struct bsc_subscr {
 	struct llist_head entry;
-	int use_count;
+	struct osmo_use_count use_count;
 
 	char imsi[GSM23003_IMSI_MAX_DIGITS+1];
 	uint32_t tmsi;
@@ -22,25 +23,29 @@
 const char *bsc_subscr_id(struct bsc_subscr *bsub);
 
 struct bsc_subscr *bsc_subscr_find_or_create_by_imsi(struct llist_head *list,
-						     const char *imsi);
+						     const char *imsi,
+						     const char *use_token);
 struct bsc_subscr *bsc_subscr_find_or_create_by_tmsi(struct llist_head *list,
-						     uint32_t tmsi);
-struct bsc_subscr *bsc_subscr_find_or_create_by_mi(struct llist_head *list, const struct osmo_mobile_identity *mi);
+						     uint32_t tmsi,
+						     const char *use_token);
+struct bsc_subscr *bsc_subscr_find_or_create_by_mi(struct llist_head *list, const struct osmo_mobile_identity *mi,
+						   const char *use_token);
 
 struct bsc_subscr *bsc_subscr_find_by_imsi(struct llist_head *list,
-					   const char *imsi);
+					   const char *imsi,
+					   const char *use_token);
 struct bsc_subscr *bsc_subscr_find_by_tmsi(struct llist_head *list,
-					   uint32_t tmsi);
-struct bsc_subscr *bsc_subscr_find_by_mi(struct llist_head *list, const struct osmo_mobile_identity *mi);
+					   uint32_t tmsi,
+					   const char *use_token);
+struct bsc_subscr *bsc_subscr_find_by_mi(struct llist_head *list, const struct osmo_mobile_identity *mi,
+					 const char *use_token);
 
 void bsc_subscr_set_imsi(struct bsc_subscr *bsub, const char *imsi);
 
-struct bsc_subscr *_bsc_subscr_get(struct bsc_subscr *bsub,
-				   const char *file, int line);
-struct bsc_subscr *_bsc_subscr_put(struct bsc_subscr *bsub,
-				   const char *file, int line);
-#define bsc_subscr_get(bsub) _bsc_subscr_get(bsub, __FILE__, __LINE__)
-#define bsc_subscr_put(bsub) _bsc_subscr_put(bsub, __FILE__, __LINE__)
+#define bsc_subscr_get(bsc_subscr, use) \
+	OSMO_ASSERT(osmo_use_count_get_put(&(bsc_subscr)->use_count, use, 1) == 0)
+#define bsc_subscr_put(bsc_subscr, use) \
+	OSMO_ASSERT(osmo_use_count_get_put(&(bsc_subscr)->use_count, use, -1) == 0)
 
 void log_set_filter_bsc_subscr(struct log_target *target,
 			       struct bsc_subscr *bsub);
diff --git a/include/osmocom/bsc/paging.h b/include/osmocom/bsc/paging.h
index c6eb9df..cd351cb 100644
--- a/include/osmocom/bsc/paging.h
+++ b/include/osmocom/bsc/paging.h
@@ -42,6 +42,9 @@
 #define LOG_PAGING_BTS(PARAMS, BTS, SUBSYS, LEVEL, fmt, args...) \
 	LOG_PAGING(PARAMS, SUBSYS, LEVEL, "(bts%u) " fmt, (BTS) ? (BTS)->nr : 255, ##args)
 
+#define BSUB_USE_PAGING_START "paging-start"
+#define BSUB_USE_PAGING_REQUEST "paging-req"
+
 /* Bitmask of reasons for Paging. Each individual Paging via bsc_paging_start() typically has only one of these reasons
  * set, but when a subscriber responds, we need to aggregate all pending Paging reasons (by bitwise-OR). */
 enum bsc_paging_reason {
diff --git a/src/osmo-bsc/bsc_subscr_conn_fsm.c b/src/osmo-bsc/bsc_subscr_conn_fsm.c
index 95bbb12..de73a2a 100644
--- a/src/osmo-bsc/bsc_subscr_conn_fsm.c
+++ b/src/osmo-bsc/bsc_subscr_conn_fsm.c
@@ -823,7 +823,8 @@
 		OSMO_ASSERT(data);
 		mi_imsi = data;
 		if (!conn->bsub)
-			conn->bsub = bsc_subscr_find_or_create_by_imsi(conn->network->bsc_subscribers, mi_imsi->imsi);
+			conn->bsub = bsc_subscr_find_or_create_by_imsi(conn->network->bsc_subscribers, mi_imsi->imsi,
+								       BSUB_USE_CONN);
 		else {
 			/* we already have a bsc_subscr associated; maybe that subscriber has no IMSI yet? */
 			if (!conn->bsub->imsi[0])
@@ -855,7 +856,7 @@
 
 	if (conn->bsub) {
 		LOGPFSML(fi, LOGL_DEBUG, "Putting bsc_subscr\n");
-		bsc_subscr_put(conn->bsub);
+		bsc_subscr_put(conn->bsub, BSUB_USE_CONN);
 		conn->bsub = NULL;
 	}
 
diff --git a/src/osmo-bsc/bsc_subscriber.c b/src/osmo-bsc/bsc_subscriber.c
index 9ddfcaa..79d0c85 100644
--- a/src/osmo-bsc/bsc_subscriber.c
+++ b/src/osmo-bsc/bsc_subscriber.c
@@ -32,6 +32,38 @@
 #include <osmocom/bsc/bsc_subscriber.h>
 #include <osmocom/bsc/debug.h>
 
+static void bsc_subscr_free(struct bsc_subscr *bsub);
+
+static int bsub_use_cb(struct osmo_use_count_entry *e, int32_t old_use_count, const char *file, int line)
+{
+	struct bsc_subscr *bsub = e->use_count->talloc_object;
+	int32_t total;
+	int level;
+
+	if (!e->use)
+		return -EINVAL;
+
+	total = osmo_use_count_total(&bsub->use_count);
+
+	if (total == 0
+	    || (total == 1 && old_use_count == 0 && e->count == 1))
+		level = LOGL_INFO;
+	else
+		level = LOGL_DEBUG;
+
+	LOGPSRC(DREF, level, file, line, "BSC subscr %s: %s %s: now used by %s\n",
+		bsc_subscr_name(bsub),
+		(e->count - old_use_count) > 0? "+" : "-", e->use,
+		osmo_use_count_to_str_c(OTC_SELECT, &bsub->use_count));
+
+	if (e->count < 0)
+		return -ERANGE;
+
+	if (total == 0)
+		bsc_subscr_free(bsub);
+	return 0;
+}
+
 static struct bsc_subscr *bsc_subscr_alloc(struct llist_head *list)
 {
 	struct bsc_subscr *bsub;
@@ -40,13 +72,20 @@
 	if (!bsub)
 		return NULL;
 
+	bsub->tmsi = GSM_RESERVED_TMSI;
+	bsub->use_count = (struct osmo_use_count){
+		.talloc_object = bsub,
+		.use_cb = bsub_use_cb,
+	};
+
 	llist_add_tail(&bsub->entry, list);
 
 	return bsub;
 }
 
 struct bsc_subscr *bsc_subscr_find_by_imsi(struct llist_head *list,
-					   const char *imsi)
+					   const char *imsi,
+					   const char *use_token)
 {
 	struct bsc_subscr *bsub;
 
@@ -54,14 +93,17 @@
 		return NULL;
 
 	llist_for_each_entry(bsub, list, entry) {
-		if (!strcmp(bsub->imsi, imsi))
-			return bsc_subscr_get(bsub);
+		if (!strcmp(bsub->imsi, imsi)) {
+			bsc_subscr_get(bsub, use_token);
+			return bsub;
+		}
 	}
 	return NULL;
 }
 
 struct bsc_subscr *bsc_subscr_find_by_tmsi(struct llist_head *list,
-					   uint32_t tmsi)
+					   uint32_t tmsi,
+					   const char *use_token)
 {
 	struct bsc_subscr *bsub;
 
@@ -69,21 +111,24 @@
 		return NULL;
 
 	llist_for_each_entry(bsub, list, entry) {
-		if (bsub->tmsi == tmsi)
-			return bsc_subscr_get(bsub);
+		if (bsub->tmsi == tmsi) {
+			bsc_subscr_get(bsub, use_token);
+			return bsub;
+		}
 	}
 	return NULL;
 }
 
-struct bsc_subscr *bsc_subscr_find_by_mi(struct llist_head *list, const struct osmo_mobile_identity *mi)
+struct bsc_subscr *bsc_subscr_find_by_mi(struct llist_head *list, const struct osmo_mobile_identity *mi,
+					 const char *use_token)
 {
 	if (!mi)
 		return NULL;
 	switch (mi->type) {
 	case GSM_MI_TYPE_IMSI:
-		return bsc_subscr_find_by_imsi(list, mi->imsi);
+		return bsc_subscr_find_by_imsi(list, mi->imsi, use_token);
 	case GSM_MI_TYPE_TMSI:
-		return bsc_subscr_find_by_tmsi(list, mi->tmsi);
+		return bsc_subscr_find_by_tmsi(list, mi->tmsi, use_token);
 	default:
 		return NULL;
 	}
@@ -97,42 +142,47 @@
 }
 
 struct bsc_subscr *bsc_subscr_find_or_create_by_imsi(struct llist_head *list,
-						     const char *imsi)
+						     const char *imsi,
+						     const char *use_token)
 {
 	struct bsc_subscr *bsub;
-	bsub = bsc_subscr_find_by_imsi(list, imsi);
+	bsub = bsc_subscr_find_by_imsi(list, imsi, use_token);
 	if (bsub)
 		return bsub;
 	bsub = bsc_subscr_alloc(list);
 	if (!bsub)
 		return NULL;
 	bsc_subscr_set_imsi(bsub, imsi);
-	return bsc_subscr_get(bsub);
+	bsc_subscr_get(bsub, use_token);
+	return bsub;
 }
 
 struct bsc_subscr *bsc_subscr_find_or_create_by_tmsi(struct llist_head *list,
-						     uint32_t tmsi)
+						     uint32_t tmsi,
+						     const char *use_token)
 {
 	struct bsc_subscr *bsub;
-	bsub = bsc_subscr_find_by_tmsi(list, tmsi);
+	bsub = bsc_subscr_find_by_tmsi(list, tmsi, use_token);
 	if (bsub)
 		return bsub;
 	bsub = bsc_subscr_alloc(list);
 	if (!bsub)
 		return NULL;
 	bsub->tmsi = tmsi;
-	return bsc_subscr_get(bsub);
+	bsc_subscr_get(bsub, use_token);
+	return bsub;
 }
 
-struct bsc_subscr *bsc_subscr_find_or_create_by_mi(struct llist_head *list, const struct osmo_mobile_identity *mi)
+struct bsc_subscr *bsc_subscr_find_or_create_by_mi(struct llist_head *list, const struct osmo_mobile_identity *mi,
+						   const char *use_token)
 {
 	if (!mi)
 		return NULL;
 	switch (mi->type) {
 	case GSM_MI_TYPE_IMSI:
-		return bsc_subscr_find_or_create_by_imsi(list, mi->imsi);
+		return bsc_subscr_find_or_create_by_imsi(list, mi->imsi, use_token);
 	case GSM_MI_TYPE_TMSI:
-		return bsc_subscr_find_or_create_by_tmsi(list, mi->tmsi);
+		return bsc_subscr_find_or_create_by_tmsi(list, mi->tmsi, use_token);
 	default:
 		return NULL;
 	}
@@ -170,29 +220,7 @@
 	talloc_free(bsub);
 }
 
-struct bsc_subscr *_bsc_subscr_get(struct bsc_subscr *bsub,
-				   const char *file, int line)
-{
-	OSMO_ASSERT(bsub->use_count < INT_MAX);
-	bsub->use_count++;
-	LOGPSRC(DREF, LOGL_DEBUG, file, line,
-		"BSC subscr %s usage increases to: %d\n",
-		bsc_subscr_name(bsub), bsub->use_count);
-	return bsub;
-}
-
-struct bsc_subscr *_bsc_subscr_put(struct bsc_subscr *bsub,
-				   const char *file, int line)
-{
-	bsub->use_count--;
-	LOGPSRC(DREF, bsub->use_count >= 0? LOGL_DEBUG : LOGL_ERROR,
-		file, line,
-		"BSC subscr %s usage decreases to: %d\n",
-		bsc_subscr_name(bsub), bsub->use_count);
-	if (bsub->use_count <= 0)
-		bsc_subscr_free(bsub);
-	return NULL;
-}
+#define BSUB_USE_LOG_FILTER "log_filter"
 
 void log_set_filter_bsc_subscr(struct log_target *target,
 			       struct bsc_subscr *bsc_subscr)
@@ -201,13 +229,14 @@
 
 	/* free the old data */
 	if (*fsub) {
-		bsc_subscr_put(*fsub);
+		bsc_subscr_put(*fsub, BSUB_USE_LOG_FILTER);
 		*fsub = NULL;
 	}
 
 	if (bsc_subscr) {
 		target->filter_map |= (1 << LOG_FLT_BSC_SUBSCR);
-		*fsub = bsc_subscr_get(bsc_subscr);
+		*fsub = bsc_subscr;
+		bsc_subscr_get(*fsub, BSUB_USE_LOG_FILTER);
 	} else
 		target->filter_map &= ~(1 << LOG_FLT_BSC_SUBSCR);
 }
diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index 7be6aeb..cd7d0e0 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -1415,7 +1415,7 @@
 	if (bsub->tmsi != GSM_RESERVED_TMSI)
 		vty_out(vty, "    TMSI: 0x%08x%s", bsub->tmsi,
 			VTY_NEWLINE);
-	vty_out(vty, "    Use count: %d%s", bsub->use_count, VTY_NEWLINE);
+	vty_out(vty, "    Use count: %s%s", osmo_use_count_to_str_c(OTC_SELECT, &bsub->use_count), VTY_NEWLINE);
 }
 
 static void meas_rep_dump_uni_vty(struct vty *vty,
@@ -6350,7 +6350,7 @@
 	if (!tgt)
 		return CMD_WARNING;
 
-	bsc_subscr = bsc_subscr_find_or_create_by_imsi(bsc_gsmnet->bsc_subscribers, imsi);
+	bsc_subscr = bsc_subscr_find_or_create_by_imsi(bsc_gsmnet->bsc_subscribers, imsi, __func__);
 
 	if (!bsc_subscr) {
 		vty_out(vty, "%% failed to enable logging for subscriber with IMSI(%s)%s",
@@ -6360,14 +6360,14 @@
 
 	log_set_filter_bsc_subscr(tgt, bsc_subscr);
 	/* log_set_filter has grabbed its own reference  */
-	bsc_subscr_put(bsc_subscr);
+	bsc_subscr_put(bsc_subscr, __func__);
 
 	return CMD_SUCCESS;
 }
 
 static void dump_one_sub(struct vty *vty, struct bsc_subscr *bsub)
 {
-	vty_out(vty, " %15s  %08x  %d%s", bsub->imsi, bsub->tmsi, bsub->use_count,
+	vty_out(vty, " %15s  %08x  %s%s", bsub->imsi, bsub->tmsi, osmo_use_count_to_str_c(OTC_SELECT, &bsub->use_count),
 		VTY_NEWLINE);
 }
 
diff --git a/src/osmo-bsc/gsm_08_08.c b/src/osmo-bsc/gsm_08_08.c
index e5a2774..01d9d0e 100644
--- a/src/osmo-bsc/gsm_08_08.c
+++ b/src/osmo-bsc/gsm_08_08.c
@@ -402,7 +402,7 @@
 		 * See e.g.  BSC_Tests.TC_chan_rel_rll_rel_ind: "dt := * f_est_dchan('23'O, 23, '00010203040506'O);"
 		 */
 	} else {
-		bsub = bsc_subscr_find_or_create_by_mi(bsc_gsmnet->bsc_subscribers, &mi);
+		bsub = bsc_subscr_find_or_create_by_mi(bsc_gsmnet->bsc_subscribers, &mi, __func__);
 	}
 
 	/* allocate a new connection */
@@ -412,8 +412,13 @@
 		goto early_fail;
 	}
 	if (bsub) {
-		/* pass bsub use count to conn */
-		conn->bsub = bsub;
+		/* We got the conn either from new allocation, or by searching for it by bsub. So: */
+		OSMO_ASSERT((!conn->bsub) || (conn->bsub == bsub));
+		if (!conn->bsub) {
+			conn->bsub = bsub;
+			bsc_subscr_get(conn->bsub, BSUB_USE_CONN);
+		}
+		bsc_subscr_put(bsub, __func__);
 	}
 	gscon_change_primary_lchan(conn, lchan);
 	gscon_update_id(conn);
diff --git a/src/osmo-bsc/osmo_bsc_bssap.c b/src/osmo-bsc/osmo_bsc_bssap.c
index 023929c..124f613 100644
--- a/src/osmo-bsc/osmo_bsc_bssap.c
+++ b/src/osmo-bsc/osmo_bsc_bssap.c
@@ -347,7 +347,8 @@
 	rate_ctr_inc(&bsc_gsmnet->bsc_ctrs->ctr[BSC_CTR_PAGING_ATTEMPTED]);
 
 	if (!params->bsub) {
-		params->bsub = bsc_subscr_find_or_create_by_imsi(bsc_gsmnet->bsc_subscribers, params->imsi.imsi);
+		params->bsub = bsc_subscr_find_or_create_by_imsi(bsc_gsmnet->bsc_subscribers, params->imsi.imsi,
+								 BSUB_USE_PAGING_START);
 		if (!params->bsub) {
 			LOG_PAGING(params, DMSC, LOGL_ERROR, "Paging request failed: Could not allocate subscriber\n");
 			return -EINVAL;
@@ -394,7 +395,7 @@
 		break;
 	}
 
-	bsc_subscr_put(params->bsub);
+	bsc_subscr_put(params->bsub, BSUB_USE_PAGING_START);
 	log_set_context(LOG_CTX_BSC_SUBSCR, NULL);
 	return 0;
 }
diff --git a/src/osmo-bsc/paging.c b/src/osmo-bsc/paging.c
index 54a5fd7..a4a5a1e 100644
--- a/src/osmo-bsc/paging.c
+++ b/src/osmo-bsc/paging.c
@@ -67,7 +67,7 @@
 {
 	osmo_timer_del(&to_be_deleted->T3113);
 	llist_del(&to_be_deleted->entry);
-	bsc_subscr_put(to_be_deleted->bsub);
+	bsc_subscr_put(to_be_deleted->bsub, BSUB_USE_PAGING_REQUEST);
 	talloc_free(to_be_deleted);
 }
 
@@ -343,7 +343,8 @@
 	req = talloc_zero(tall_paging_ctx, struct gsm_paging_request);
 	OSMO_ASSERT(req);
 	req->reason = params->reason;
-	req->bsub = bsc_subscr_get(params->bsub);
+	req->bsub = params->bsub;
+	bsc_subscr_get(req->bsub, BSUB_USE_PAGING_REQUEST);
 	req->bts = bts;
 	req->chan_type = params->chan_needed;
 	req->msc = params->msc;
diff --git a/tests/handover/handover_test.c b/tests/handover/handover_test.c
index bdf926d..8fa8fe8 100644
--- a/tests/handover/handover_test.c
+++ b/tests/handover/handover_test.c
@@ -244,7 +244,7 @@
 	/* Make up a new IMSI for this test, for logging the subscriber */
 	next_imsi ++;
 	snprintf(imsi, sizeof(imsi), "%06u", next_imsi);
-	lchan->conn->bsub = bsc_subscr_find_or_create_by_imsi(net->bsc_subscribers, imsi);
+	lchan->conn->bsub = bsc_subscr_find_or_create_by_imsi(net->bsc_subscribers, imsi, BSUB_USE_CONN);
 
 	/* kick the FSM from INIT through to the ACTIVE state */
 	osmo_fsm_inst_dispatch(conn->fi, GSCON_EV_A_CONN_REQ, NULL);
diff --git a/tests/subscr/bsc_subscr_test.c b/tests/subscr/bsc_subscr_test.c
index 3c94b86..fcaea63 100644
--- a/tests/subscr/bsc_subscr_test.c
+++ b/tests/subscr/bsc_subscr_test.c
@@ -37,16 +37,18 @@
 		OSMO_ASSERT((val) expect_op); \
 	} while (0);
 
+#define BSUB_USE "test"
+
 static void assert_bsc_subscr(const struct bsc_subscr *bsub, const char *imsi)
 {
 	struct bsc_subscr *sfound;
 	OSMO_ASSERT(bsub);
 	OSMO_ASSERT(strcmp(bsub->imsi, imsi) == 0);
 
-	sfound = bsc_subscr_find_by_imsi(bsc_subscribers, imsi);
+	sfound = bsc_subscr_find_by_imsi(bsc_subscribers, imsi, BSUB_USE);
 	OSMO_ASSERT(sfound == bsub);
 
-	bsc_subscr_put(sfound);
+	bsc_subscr_put(sfound, BSUB_USE);
 }
 
 static void test_bsc_subscr(void)
@@ -60,23 +62,23 @@
 
 	/* Check for emptiness */
 	VERBOSE_ASSERT(llist_count(bsc_subscribers), == 0, "%d");
-	OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL);
-	OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL);
-	OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi3) == NULL);
+	OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1, BSUB_USE) == NULL);
+	OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2, BSUB_USE) == NULL);
+	OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi3, BSUB_USE) == NULL);
 
 	/* Allocate entry 1 */
-	s1 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi1);
+	s1 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi1, BSUB_USE);
 	VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d");
 	assert_bsc_subscr(s1, imsi1);
 	VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d");
-	OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL);
+	OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2, BSUB_USE) == NULL);
 
 	/* Allocate entry 2 */
-	s2 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi2);
+	s2 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi2, BSUB_USE);
 	VERBOSE_ASSERT(llist_count(bsc_subscribers), == 2, "%d");
 
 	/* Allocate entry 3 */
-	s3 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi3);
+	s3 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi3, BSUB_USE);
 	VERBOSE_ASSERT(llist_count(bsc_subscribers), == 3, "%d");
 
 	/* Check entries */
@@ -85,27 +87,27 @@
 	assert_bsc_subscr(s3, imsi3);
 
 	/* Free entry 1 */
-	bsc_subscr_put(s1);
+	bsc_subscr_put(s1, BSUB_USE);
 	s1 = NULL;
 	VERBOSE_ASSERT(llist_count(bsc_subscribers), == 2, "%d");
-	OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL);
+	OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1, BSUB_USE) == NULL);
 
 	assert_bsc_subscr(s2, imsi2);
 	assert_bsc_subscr(s3, imsi3);
 
 	/* Free entry 2 */
-	bsc_subscr_put(s2);
+	bsc_subscr_put(s2, BSUB_USE);
 	s2 = NULL;
 	VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d");
-	OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL);
-	OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL);
+	OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1, BSUB_USE) == NULL);
+	OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2, BSUB_USE) == NULL);
 	assert_bsc_subscr(s3, imsi3);
 
 	/* Free entry 3 */
-	bsc_subscr_put(s3);
+	bsc_subscr_put(s3, BSUB_USE);
 	s3 = NULL;
 	VERBOSE_ASSERT(llist_count(bsc_subscribers), == 0, "%d");
-	OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi3) == NULL);
+	OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi3, BSUB_USE) == NULL);
 
 	OSMO_ASSERT(llist_empty(bsc_subscribers));
 }
diff --git a/tests/subscr/bsc_subscr_test.err b/tests/subscr/bsc_subscr_test.err
index afc8bf7..a78e757 100644
--- a/tests/subscr/bsc_subscr_test.err
+++ b/tests/subscr/bsc_subscr_test.err
@@ -1,20 +1,20 @@
-DREF BSC subscr IMSI:1234567890 usage increases to: 1
-DREF BSC subscr IMSI:1234567890 usage increases to: 2
-DREF BSC subscr IMSI:1234567890 usage decreases to: 1
-DREF BSC subscr IMSI:9876543210 usage increases to: 1
-DREF BSC subscr IMSI:5656565656 usage increases to: 1
-DREF BSC subscr IMSI:1234567890 usage increases to: 2
-DREF BSC subscr IMSI:1234567890 usage decreases to: 1
-DREF BSC subscr IMSI:9876543210 usage increases to: 2
-DREF BSC subscr IMSI:9876543210 usage decreases to: 1
-DREF BSC subscr IMSI:5656565656 usage increases to: 2
-DREF BSC subscr IMSI:5656565656 usage decreases to: 1
-DREF BSC subscr IMSI:1234567890 usage decreases to: 0
-DREF BSC subscr IMSI:9876543210 usage increases to: 2
-DREF BSC subscr IMSI:9876543210 usage decreases to: 1
-DREF BSC subscr IMSI:5656565656 usage increases to: 2
-DREF BSC subscr IMSI:5656565656 usage decreases to: 1
-DREF BSC subscr IMSI:9876543210 usage decreases to: 0
-DREF BSC subscr IMSI:5656565656 usage increases to: 2
-DREF BSC subscr IMSI:5656565656 usage decreases to: 1
-DREF BSC subscr IMSI:5656565656 usage decreases to: 0
+DREF BSC subscr IMSI:1234567890: + test: now used by 1 (test)
+DREF BSC subscr IMSI:1234567890: + test: now used by 2 (2*test)
+DREF BSC subscr IMSI:1234567890: - test: now used by 1 (test)
+DREF BSC subscr IMSI:9876543210: + test: now used by 1 (test)
+DREF BSC subscr IMSI:5656565656: + test: now used by 1 (test)
+DREF BSC subscr IMSI:1234567890: + test: now used by 2 (2*test)
+DREF BSC subscr IMSI:1234567890: - test: now used by 1 (test)
+DREF BSC subscr IMSI:9876543210: + test: now used by 2 (2*test)
+DREF BSC subscr IMSI:9876543210: - test: now used by 1 (test)
+DREF BSC subscr IMSI:5656565656: + test: now used by 2 (2*test)
+DREF BSC subscr IMSI:5656565656: - test: now used by 1 (test)
+DREF BSC subscr IMSI:1234567890: - test: now used by 0 (-)
+DREF BSC subscr IMSI:9876543210: + test: now used by 2 (2*test)
+DREF BSC subscr IMSI:9876543210: - test: now used by 1 (test)
+DREF BSC subscr IMSI:5656565656: + test: now used by 2 (2*test)
+DREF BSC subscr IMSI:5656565656: - test: now used by 1 (test)
+DREF BSC subscr IMSI:9876543210: - test: now used by 0 (-)
+DREF BSC subscr IMSI:5656565656: + test: now used by 2 (2*test)
+DREF BSC subscr IMSI:5656565656: - test: now used by 1 (test)
+DREF BSC subscr IMSI:5656565656: - test: now used by 0 (-)

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/20351
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I29bf60059d4cf7bb99a00753e6cdc149baf95f94
Gerrit-Change-Number: 20351
Gerrit-PatchSet: 4
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201007/262259b5/attachment.htm>


More information about the gerrit-log mailing list