From 6cf8a532d4f2536b4cc99ba8d3486416d794503c Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 11 Apr 2023 10:44:36 +1000 Subject: [PATCH] Atomically increase rrn in add_other_data 'rrn' needs to be treated atomically as it updated from multiple threads. --- bin/tests/system/rpz/testlib/test-data.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/tests/system/rpz/testlib/test-data.c b/bin/tests/system/rpz/testlib/test-data.c index 0906702090..16f5fbb6fa 100644 --- a/bin/tests/system/rpz/testlib/test-data.c +++ b/bin/tests/system/rpz/testlib/test-data.c @@ -37,6 +37,7 @@ #include #include +#include #include #include "test-data.h" @@ -392,13 +393,13 @@ add_other_rr(trpz_result_t *node, const char *rrtype, const char *val, uint32_t ttl, int *modified) { trpz_rr_t nrec = { 0 }; size_t n; - static unsigned int rrn = 1; + static atomic_uint_fast32_t rrn = 1; *modified = 0; nrec.class = ns_c_in; nrec.ttl = ttl; - nrec.rrn = rrn++; + nrec.rrn = atomic_fetch_add_relaxed(&rrn, 1); if (!strcasecmp(rrtype, "A")) { uint32_t addr;