diff --git a/lib/dns/adb.c b/lib/dns/adb.c index a81ebddc1b..ef92322afa 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -935,7 +935,7 @@ clean_finds_at_name(dns_adbname_t *name, dns_adbstatus_t astat, INSIST(!FIND_EVENTSENT(find)); - find->status = astat; + atomic_store(&find->status, astat); DP(DEF_LEVEL, "cfan: sending find %p to caller", find); @@ -2222,7 +2222,7 @@ post_copy: if (want_event) { INSIST((find->flags & DNS_ADBFIND_ADDRESSMASK) != 0); find->loop = loop; - find->status = DNS_ADB_UNSET; + atomic_store(&find->status, DNS_ADB_UNSET); find->cb = cb; find->cbarg = cbarg; } @@ -2276,7 +2276,7 @@ dns_adb_destroyfind(dns_adbfind_t **findp) { static void find_sendevent(dns_adbfind_t *find) { if (!FIND_EVENTSENT(find)) { - find->status = DNS_ADB_CANCELED; + atomic_store(&find->status, DNS_ADB_CANCELED); DP(DEF_LEVEL, "sending find %p to caller", find); @@ -2323,14 +2323,9 @@ dns_adb_cancelfind(dns_adbfind_t *find) { unsigned int dns_adb_findstatus(dns_adbfind_t *find) { - unsigned int status; REQUIRE(DNS_ADBFIND_VALID(find)); - UNLOCK(&find->lock); - status = find->status; - UNLOCK(&find->lock); - - return (status); + return (atomic_load(&find->status)); } void diff --git a/lib/dns/include/dns/adb.h b/lib/dns/include/dns/adb.h index 9b40ab8f26..91f7039b73 100644 --- a/lib/dns/include/dns/adb.h +++ b/lib/dns/include/dns/adb.h @@ -121,15 +121,15 @@ struct dns_adbfind { ISC_LINK(dns_adbfind_t) publink; /*%< RW: client use */ /* Private */ - isc_mutex_t lock; /* locks all below */ - in_port_t port; - unsigned int flags; - dns_adbname_t *adbname; - dns_adb_t *adb; - isc_loop_t *loop; - dns_adbstatus_t status; - isc_job_cb cb; - void *cbarg; + isc_mutex_t lock; /* locks all below */ + in_port_t port; + unsigned int flags; + dns_adbname_t *adbname; + dns_adb_t *adb; + isc_loop_t *loop; + _Atomic(dns_adbstatus_t) status; + isc_job_cb cb; + void *cbarg; ISC_LINK(dns_adbfind_t) plink; };