2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

Special, for-tests-only, mode with atomics emulated by a mutex-locked variable - useful for finding atomics congestions

This commit is contained in:
Witold Kręcicki
2019-05-17 11:35:35 +02:00
parent 5aeb99786e
commit 92424e23fa
7 changed files with 228 additions and 22 deletions

View File

@@ -5692,6 +5692,15 @@ recparam_update(ns_query_recparam_t *param, dns_rdatatype_t qtype,
RUNTIME_CHECK(result == ISC_R_SUCCESS);
}
}
static atomic_uint_fast32_t last_soft, last_hard;
#ifdef ISC_MUTEX_ATOMICS
static isc_once_t last_once = ISC_ONCE_INIT;
static void last_init() {
atomic_init(&last_soft, 0);
atomic_init(&last_hard, 0);
}
#endif
isc_result_t
ns_query_recurse(ns_client_t *client, dns_rdatatype_t qtype, dns_name_t *qname,
@@ -5739,16 +5748,13 @@ ns_query_recurse(ns_client_t *client, dns_rdatatype_t qtype, dns_name_t *qname,
}
if (result == ISC_R_SOFTQUOTA) {
static atomic_uint_fast32_t last;
static isc_once_t once = ISC_ONCE_INIT;
void __ain() {
atomic_init(&last, 0);
}
isc_once_do(&once, __ain);
#ifdef ISC_MUTEX_ATOMICS
isc_once_do(&last_once, last_init);
#endif
isc_stdtime_t now;
isc_stdtime_get(&now);
if (now != atomic_load_relaxed(&last)) {
atomic_store_relaxed(&last, now);
if (now != atomic_load_relaxed(&last_soft)) {
atomic_store_relaxed(&last_soft, now);
ns_client_log(client, NS_LOGCATEGORY_CLIENT,
NS_LOGMODULE_QUERY, ISC_LOG_WARNING,
"recursive-clients soft limit "
@@ -5761,17 +5767,14 @@ ns_query_recurse(ns_client_t *client, dns_rdatatype_t qtype, dns_name_t *qname,
ns_client_killoldestquery(client);
result = ISC_R_SUCCESS;
} else if (result == ISC_R_QUOTA) {
static atomic_uint_fast32_t last;
static isc_once_t once = ISC_ONCE_INIT;
void __ain() {
atomic_init(&last, 0);
}
isc_once_do(&once, __ain);
#ifdef ISC_MUTEX_ATOMICS
isc_once_do(&last_once, last_init);
#endif
isc_stdtime_t now;
isc_stdtime_get(&now);
if (now != atomic_load_relaxed(&last)) {
if (now != atomic_load_relaxed(&last_hard)) {
ns_server_t *sctx = client->sctx;
atomic_store_relaxed(&last, now);
atomic_store_relaxed(&last_hard, now);
ns_client_log(client, NS_LOGCATEGORY_CLIENT,
NS_LOGMODULE_QUERY, ISC_LOG_WARNING,
"no more recursive clients "