aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2020-09-15 01:03:58 +0000
committerNeels Hofmeyr <neels@hofmeyr.de>2020-10-07 11:40:12 +0000
commit86a1dca5c765f3abdd3b01f4ba49217dbc0f34e0 (patch)
tree0023b9f53544b7a73386a0b030a9d56a6e866338
parentd4946b22f7607d93095386e418ff29e456c243a2 (diff)
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
-rw-r--r--include/osmocom/bsc/bsc_subscr_conn_fsm.h2
-rw-r--r--include/osmocom/bsc/bsc_subscriber.h31
-rw-r--r--include/osmocom/bsc/paging.h3
-rw-r--r--src/osmo-bsc/bsc_subscr_conn_fsm.c5
-rw-r--r--src/osmo-bsc/bsc_subscriber.c115
-rw-r--r--src/osmo-bsc/bsc_vty.c8
-rw-r--r--src/osmo-bsc/gsm_08_08.c11
-rw-r--r--src/osmo-bsc/osmo_bsc_bssap.c5
-rw-r--r--src/osmo-bsc/paging.c5
-rw-r--r--tests/handover/handover_test.c2
-rw-r--r--tests/subscr/bsc_subscr_test.c34
-rw-r--r--tests/subscr/bsc_subscr_test.err40
12 files changed, 155 insertions, 106 deletions
diff --git a/include/osmocom/bsc/bsc_subscr_conn_fsm.h b/include/osmocom/bsc/bsc_subscr_conn_fsm.h
index 354c5ee93..9b6398a3f 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 a602a9ef6..6fffafdb3 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 log_target;
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_name(struct bsc_subscr *bsub);
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 c6eb9dfaa..cd351cb5d 100644
--- a/include/osmocom/bsc/paging.h
+++ b/include/osmocom/bsc/paging.h
@@ -42,6 +42,9 @@ struct bsc_msc_data;
#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 95bbb12bf..de73a2a8b 100644
--- a/src/osmo-bsc/bsc_subscr_conn_fsm.c
+++ b/src/osmo-bsc/bsc_subscr_conn_fsm.c
@@ -823,7 +823,8 @@ static void gscon_fsm_allstate(struct osmo_fsm_inst *fi, uint32_t event, void *d
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 @@ static void gscon_cleanup(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cau
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 9ddfcaa43..79d0c8512 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 @@ static struct bsc_subscr *bsc_subscr_alloc(struct llist_head *list)
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 @@ struct bsc_subscr *bsc_subscr_find_by_imsi(struct llist_head *list,
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 @@ struct bsc_subscr *bsc_subscr_find_by_tmsi(struct llist_head *list,
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 @@ void bsc_subscr_set_imsi(struct bsc_subscr *bsub, const char *imsi)
}
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 @@ static void bsc_subscr_free(struct bsc_subscr *bsub)
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 @@ void log_set_filter_bsc_subscr(struct log_target *target,
/* 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 7be6aebd3..cd7d0e001 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -1415,7 +1415,7 @@ static void bsc_subscr_dump_vty(struct vty *vty, struct bsc_subscr *bsub)
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 @@ DEFUN(logging_fltr_imsi,
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 @@ DEFUN(logging_fltr_imsi,
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 e5a27748f..01d9d0ee3 100644
--- a/src/osmo-bsc/gsm_08_08.c
+++ b/src/osmo-bsc/gsm_08_08.c
@@ -402,7 +402,7 @@ int bsc_compl_l3(struct gsm_lchan *lchan, struct msgb *msg, uint16_t chosen_chan
* 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 @@ int bsc_compl_l3(struct gsm_lchan *lchan, struct msgb *msg, uint16_t chosen_chan
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 023929cb5..124f61353 100644
--- a/src/osmo-bsc/osmo_bsc_bssap.c
+++ b/src/osmo-bsc/osmo_bsc_bssap.c
@@ -347,7 +347,8 @@ int bsc_paging_start(struct bsc_paging_params *params)
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 @@ int bsc_paging_start(struct bsc_paging_params *params)
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 54a5fd7cd..a4a5a1e68 100644
--- a/src/osmo-bsc/paging.c
+++ b/src/osmo-bsc/paging.c
@@ -67,7 +67,7 @@ static void paging_remove_request(struct gsm_bts_paging_state *paging_bts,
{
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 @@ static int _paging_request(const struct bsc_paging_params *params, struct gsm_bt
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 bdf926d8a..8fa8fe84a 100644
--- a/tests/handover/handover_test.c
+++ b/tests/handover/handover_test.c
@@ -244,7 +244,7 @@ void create_conn(struct gsm_lchan *lchan)
/* 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 3c94b8662..fcaea63eb 100644
--- a/tests/subscr/bsc_subscr_test.c
+++ b/tests/subscr/bsc_subscr_test.c
@@ -37,16 +37,18 @@ struct llist_head *bsc_subscribers;
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 @@ static void test_bsc_subscr(void)
/* 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 @@ static void test_bsc_subscr(void)
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 afc8bf778..a78e7576a 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 (-)