]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use atomic store operations instead of atomic initialize
authorAram Sargsyan <aram@isc.org>
Fri, 15 Dec 2023 09:43:36 +0000 (09:43 +0000)
committerAram Sargsyan <aram@isc.org>
Fri, 15 Dec 2023 09:56:44 +0000 (09:56 +0000)
The atomic_init() function makes sense to use with structure's
members when creating a new instance of a strucutre. In other
places, use atomic store operations instead, in order to avoid
data races.

lib/dns/xfrin.c

index 148449ce626a3ca88d2462c351fc9c96bf8e2ece..697e8507c902bb51f320cef528ae0d105b424437 100644 (file)
@@ -1260,8 +1260,8 @@ xfrin_start(dns_xfrin_t *xfr) {
                 * The "SOA before" mode is used, where the SOA request is
                 * using the same transport as the XFR.
                 */
-               atomic_init(&xfr->soa_transport_type,
-                           dns_xfrin_gettransporttype(xfr));
+               atomic_store_relaxed(&xfr->soa_transport_type,
+                                    dns_xfrin_gettransporttype(xfr));
        }
 
        /* Set the maximum timer */
@@ -1552,10 +1552,10 @@ xfrin_send_request(dns_xfrin_t *xfr) {
                CHECK(add_opt(msg, udpsize, reqnsid, reqexpire));
        }
 
-       atomic_init(&xfr->nmsg, 0);
-       atomic_init(&xfr->nrecs, 0);
-       atomic_init(&xfr->nbytes, 0);
-       atomic_init(&xfr->start, isc_time_now());
+       atomic_store_relaxed(&xfr->nmsg, 0);
+       atomic_store_relaxed(&xfr->nrecs, 0);
+       atomic_store_relaxed(&xfr->nbytes, 0);
+       atomic_store_relaxed(&xfr->start, isc_time_now());
 
        msg->id = xfr->id;
        if (xfr->tsigctx != NULL) {