]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Atomically increase rrn in add_other_data
authorMark Andrews <marka@isc.org>
Tue, 11 Apr 2023 00:44:36 +0000 (10:44 +1000)
committerMark Andrews <marka@isc.org>
Tue, 11 Apr 2023 00:44:36 +0000 (10:44 +1000)
'rrn' needs to be treated atomically as it updated from multiple threads.

bin/tests/system/rpz/testlib/test-data.c

index 090670209011e7810b4fc42df566594bb96aae98..16f5fbb6fa7f287e46082af01f65b489db759a3a 100644 (file)
@@ -37,6 +37,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+#include <isc/atomic.h>
 #include <isc/util.h>
 
 #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;