2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

Use atomics to access find->status

This commit is contained in:
Mark Andrews 2024-07-16 13:36:54 +10:00
parent c900300f21
commit a45e39d114
2 changed files with 13 additions and 18 deletions

View File

@ -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

View File

@ -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;
};