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/.
Max gerrit-no-reply at lists.osmocom.org
Review at https://gerrit.osmocom.org/5418
Do not allocate already existing counter group
Check that no group with the given name and index already exist before
allocating it. Add corresponding test case.
Change-Id: I563764af1d28043e909234ebb048239125ce6ecd
Related: OS#2757
---
M src/rate_ctr.c
M tests/stats/stats_test.c
2 files changed, 9 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/18/5418/1
diff --git a/src/rate_ctr.c b/src/rate_ctr.c
index 477339f..c27ac68 100644
--- a/src/rate_ctr.c
+++ b/src/rate_ctr.c
@@ -190,6 +190,9 @@
unsigned int size;
struct rate_ctr_group *group;
+ if (rate_ctr_get_group_by_name_idx(desc->group_name_prefix, idx))
+ return NULL; /* group already exist */
+
size = sizeof(struct rate_ctr_group) +
desc->num_ctr * sizeof(struct rate_ctr);
diff --git a/tests/stats/stats_test.c b/tests/stats/stats_test.c
index b302b37..35faf9a 100644
--- a/tests/stats/stats_test.c
+++ b/tests/stats/stats_test.c
@@ -311,7 +311,7 @@
{
struct osmo_stats_reporter *srep1, *srep2, *srep;
struct osmo_stat_item_group *statg1, *statg2;
- struct rate_ctr_group *ctrg1, *ctrg2, *ctrg3;
+ struct rate_ctr_group *ctrg1, *ctrg2, *ctrg3, *ctrg_dup;
void *stats_ctx = talloc_named_const(NULL, 1, "stats test context");
int rc;
@@ -327,6 +327,11 @@
OSMO_ASSERT(ctrg1 != NULL);
ctrg2 = rate_ctr_group_alloc(stats_ctx, &ctrg_desc, 2);
OSMO_ASSERT(ctrg2 != NULL);
+
+ ctrg_dup = rate_ctr_group_alloc(stats_ctx, &ctrg_desc, 2);
+ if (ctrg_dup != NULL && ctrg2 != NULL)
+ printf("FAIL: successfully allocated already existing counter group!\n");
+
ctrg3 = rate_ctr_group_alloc(stats_ctx, &ctrg_desc_dot, 3);
OSMO_ASSERT(ctrg3 != NULL);
--
To view, visit https://gerrit.osmocom.org/5418
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I563764af1d28043e909234ebb048239125ce6ecd
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>