[PATCH] libosmocore[master]: rate_ctr_group_alloc: use ctx; adjust stats_test

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 Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri Nov 17 00:27:52 UTC 2017


Review at  https://gerrit.osmocom.org/4868

rate_ctr_group_alloc: use ctx; adjust stats_test

Using the NULL context creates mem leaks that bother sanitizer builds.
Allocating from the rate counter context allows cleaning up at the end of
stats_test.

Remove the comment concerning osmo-msc: one way to fix if the talloc becomes
unexpected from this patch is to adjust the talloc expectations, another
(preferred) way is to have no invalid rate counter names in osmo-msc.

Change-Id: Ief9abfeb78b7706200bcc6aaa5dcb04fbeaa9b5b
---
M src/rate_ctr.c
M tests/stats/stats_test.c
2 files changed, 2 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/68/4868/1

diff --git a/src/rate_ctr.c b/src/rate_ctr.c
index deb9874..a6f2c45 100644
--- a/src/rate_ctr.c
+++ b/src/rate_ctr.c
@@ -199,9 +199,7 @@
 
 	/* attempt to mangle all '.' in identifiers to ':' for backwards compat */
 	if (!rate_ctrl_group_desc_validate(desc, true)) {
-		/* don't use 'ctx' here as it would screw up memory leak debugging e.g.
-		 * in osmo-msc */
-		desc = rate_ctr_group_desc_mangle(NULL, desc);
+		desc = rate_ctr_group_desc_mangle(ctx, desc);
 		if (!desc)
 			return NULL;
 	}
diff --git a/tests/stats/stats_test.c b/tests/stats/stats_test.c
index 054fa78..4dddc08 100644
--- a/tests/stats/stats_test.c
+++ b/tests/stats/stats_test.c
@@ -472,7 +472,7 @@
 	OSMO_ASSERT(talloc_total_blocks(ctr_ctx) == 1);
 	talloc_free(ctr_ctx);
 
-	OSMO_ASSERT(talloc_total_blocks(ctr_with_dot_ctx) == 1);
+	OSMO_ASSERT(talloc_total_blocks(ctr_with_dot_ctx) == 6);
 	talloc_free(ctr_with_dot_ctx);
 
 	printf("End test: %s\n", __func__);

-- 
To view, visit https://gerrit.osmocom.org/4868
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ief9abfeb78b7706200bcc6aaa5dcb04fbeaa9b5b
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list