Change dns_adbentry_overquota() to dns_adb_overquota()
The dns_adbentry_overquota() was violating the layers accessing the adbentry struct members directly. Change it to dns_adb_overquota() to match the dns_adb API.
This commit is contained in:
+16
-8
@@ -388,6 +388,9 @@ adjustsrtt(dns_adbaddrinfo_t *addr, unsigned int rtt, unsigned int factor,
|
||||
static void
|
||||
log_quota(dns_adbentry_t *entry, const char *fmt, ...) ISC_FORMAT_PRINTF(2, 3);
|
||||
|
||||
static bool
|
||||
adbentry_overquota(dns_adbentry_t *entry);
|
||||
|
||||
/*
|
||||
* MUST NOT overlap DNS_ADBFIND_* flags!
|
||||
*/
|
||||
@@ -1567,7 +1570,7 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find,
|
||||
entry = namehook->entry;
|
||||
LOCK(&entry->lock);
|
||||
|
||||
if (dns_adbentry_overquota(entry)) {
|
||||
if (adbentry_overquota(entry)) {
|
||||
find->options |= (DNS_ADBFIND_LAMEPRUNED |
|
||||
DNS_ADBFIND_OVERQUOTA);
|
||||
goto nextv4;
|
||||
@@ -1599,7 +1602,7 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find,
|
||||
entry = namehook->entry;
|
||||
LOCK(&entry->lock);
|
||||
|
||||
if (dns_adbentry_overquota(entry)) {
|
||||
if (adbentry_overquota(entry)) {
|
||||
find->options |= (DNS_ADBFIND_LAMEPRUNED |
|
||||
DNS_ADBFIND_OVERQUOTA);
|
||||
goto nextv6;
|
||||
@@ -3714,18 +3717,23 @@ dns_adb_getquota(dns_adb_t *adb, uint32_t *quotap, uint32_t *freqp,
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
dns_adbentry_overquota(dns_adbentry_t *entry) {
|
||||
uint_fast32_t quota, active;
|
||||
|
||||
static bool
|
||||
adbentry_overquota(dns_adbentry_t *entry) {
|
||||
REQUIRE(DNS_ADBENTRY_VALID(entry));
|
||||
|
||||
quota = atomic_load_relaxed(&entry->quota);
|
||||
active = atomic_load_acquire(&entry->active);
|
||||
uint_fast32_t quota = atomic_load_relaxed(&entry->quota);
|
||||
uint_fast32_t active = atomic_load_acquire(&entry->active);
|
||||
|
||||
return (quota != 0 && active >= quota);
|
||||
}
|
||||
|
||||
bool
|
||||
dns_adb_overquota(dns_adb_t *adb ISC_ATTR_UNUSED, dns_adbaddrinfo_t *addrinfo) {
|
||||
REQUIRE(DNS_ADBADDRINFO_VALID(addrinfo));
|
||||
|
||||
return (adbentry_overquota(addrinfo->entry));
|
||||
}
|
||||
|
||||
void
|
||||
dns_adb_beginudpfetch(dns_adb_t *adb, dns_adbaddrinfo_t *addr) {
|
||||
uint_fast32_t active;
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
#include <isc/lang.h>
|
||||
#include <isc/magic.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/sockaddr.h>
|
||||
|
||||
#include <dns/types.h>
|
||||
@@ -743,7 +744,7 @@ dns_adb_getquota(dns_adb_t *adb, uint32_t *quotap, uint32_t *freqp,
|
||||
*/
|
||||
|
||||
bool
|
||||
dns_adbentry_overquota(dns_adbentry_t *entry);
|
||||
dns_adb_overquota(dns_adb_t *adb, dns_adbaddrinfo_t *addr);
|
||||
/*%<
|
||||
* Returns true if the specified ADB has too many active fetches.
|
||||
*
|
||||
|
||||
+3
-3
@@ -2100,7 +2100,7 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo,
|
||||
query->magic = QUERY_MAGIC;
|
||||
|
||||
if ((query->options & DNS_FETCHOPT_TCP) == 0) {
|
||||
if (dns_adbentry_overquota(addrinfo->entry)) {
|
||||
if (dns_adb_overquota(fctx->adb, addrinfo)) {
|
||||
UNLOCK(&fctx->lock);
|
||||
result = ISC_R_QUOTA;
|
||||
goto cleanup_dispatch;
|
||||
@@ -3964,7 +3964,7 @@ fctx_try(fetchctx_t *fctx, bool retrying, bool badcache) {
|
||||
addrinfo = fctx_nextaddress(fctx);
|
||||
|
||||
/* Try to find an address that isn't over quota */
|
||||
while (addrinfo != NULL && dns_adbentry_overquota(addrinfo->entry)) {
|
||||
while (addrinfo != NULL && dns_adb_overquota(fctx->adb, addrinfo)) {
|
||||
addrinfo = fctx_nextaddress(fctx);
|
||||
}
|
||||
|
||||
@@ -3988,7 +3988,7 @@ fctx_try(fetchctx_t *fctx, bool retrying, bool badcache) {
|
||||
addrinfo = fctx_nextaddress(fctx);
|
||||
|
||||
while (addrinfo != NULL &&
|
||||
dns_adbentry_overquota(addrinfo->entry))
|
||||
dns_adb_overquota(fctx->adb, addrinfo))
|
||||
{
|
||||
addrinfo = fctx_nextaddress(fctx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user