While this is not an issue in named, which only calls
dns_zone_asyncload() from task-exclusive mode, this function is exported
by libdns and thus may in theory be concurrently called for the same
zone by multiple threads. It also does not hurt to be consistent
locking-wise with other DNS_ZONEFLG_LOADPENDING accesses.
return (ISC_R_FAILURE);
/* If we already have a load pending, stop now */
- if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADPENDING))
+ LOCK_ZONE(zone);
+ if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADPENDING)) {
+ UNLOCK_ZONE(zone);
return (ISC_R_ALREADYRUNNING);
+ }
asl = isc_mem_get(zone->mctx, sizeof (*asl));
if (asl == NULL)
if (e == NULL)
CHECK(ISC_R_NOMEMORY);
- LOCK_ZONE(zone);
zone_iattach(zone, &asl->zone);
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_LOADPENDING);
isc_task_send(zone->loadtask, &e);
failure:
if (asl != NULL)
isc_mem_put(zone->mctx, asl, sizeof (*asl));
+ UNLOCK_ZONE(zone);
return (result);
}