summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Hák <jan.hak@nic.cz>2024-11-26 12:56:51 +0100
committerDaniel Salzman <daniel.salzman@nic.cz>2024-12-11 17:36:20 +0100
commitda55fa4e0d780dc756aefdf1459e1160efa0d660 (patch)
tree5f337e24f1ba454ce02e6ce38a9b728dc2654b99
parentmodules/probe: fix usage of new atomic in code (variable last_times) (diff)
downloadknot-da55fa4e0d780dc756aefdf1459e1160efa0d660.tar.xz
knot-da55fa4e0d780dc756aefdf1459e1160efa0d660.zip
stats: fix usage of new atomic in code (variable stats_vals)
-rw-r--r--src/knot/nameserver/query_module.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/knot/nameserver/query_module.c b/src/knot/nameserver/query_module.c
index 0708b1704..8b7d7958f 100644
--- a/src/knot/nameserver/query_module.c
+++ b/src/knot/nameserver/query_module.c
@@ -284,6 +284,10 @@ int knotd_mod_stats_add(knotd_mod_t *mod, const char *ctr_name, uint32_t idx_cou
knotd_mod_stats_free(mod);
return KNOT_ENOMEM;
}
+
+ for (unsigned j = 0; j < idx_count; j++) {
+ ATOMIC_INIT(mod->stats_vals[i][j], 0);
+ }
}
} else {
for (uint32_t i = 0; i < mod->stats_count; i++) {
@@ -311,9 +315,9 @@ int knotd_mod_stats_add(knotd_mod_t *mod, const char *ctr_name, uint32_t idx_cou
return KNOT_ENOMEM;
}
mod->stats_vals[i] = new_vals;
- new_vals += offset;
- for (uint32_t j = 0; j < idx_count; j++) {
- *new_vals++ = 0;
+
+ for (unsigned j = 0; j < idx_count; j++) {
+ ATOMIC_INIT(mod->stats_vals[i][offset + j], 0);
}
}
}
@@ -338,6 +342,9 @@ void knotd_mod_stats_free(knotd_mod_t *mod)
if (mod->stats_vals != NULL) {
unsigned threads = knotd_mod_threads(mod);
for (unsigned i = 0; i < threads; i++) {
+ for (unsigned j = 0; j < mod->stats_info->count; j++) {
+ ATOMIC_DEINIT(mod->stats_vals[i][j]);
+ }
free(mod->stats_vals[i]);
}
}