mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
Small optimization in query_usestale
This commit makes the code in query_usestale easier to follow, it also doesn't attach/detach to the database if stale answers are not enabled.
This commit is contained in:
@@ -7368,45 +7368,20 @@ root_key_sentinel_return_servfail(query_ctx_t *qctx, isc_result_t result) {
|
|||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
query_usestale(query_ctx_t *qctx) {
|
query_usestale(query_ctx_t *qctx) {
|
||||||
bool staleanswersok = false;
|
|
||||||
dns_ttl_t stale_ttl = 0;
|
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
qctx_clean(qctx);
|
qctx_clean(qctx);
|
||||||
qctx_freedata(qctx);
|
qctx_freedata(qctx);
|
||||||
|
|
||||||
/*
|
if (dns_view_staleanswerenabled(qctx->client->view)) {
|
||||||
* Stale answers only make sense if stale_ttl > 0 but we want rndc to
|
dns_db_attach(qctx->client->view->cachedb, &qctx->db);
|
||||||
* be able to control returning stale answers if they are configured.
|
|
||||||
*/
|
|
||||||
dns_db_attach(qctx->client->view->cachedb, &qctx->db);
|
|
||||||
result = dns_db_getservestalettl(qctx->db, &stale_ttl);
|
|
||||||
if (result == ISC_R_SUCCESS && stale_ttl > 0) {
|
|
||||||
switch (qctx->client->view->staleanswersok) {
|
|
||||||
case dns_stale_answer_yes:
|
|
||||||
staleanswersok = true;
|
|
||||||
break;
|
|
||||||
case dns_stale_answer_conf:
|
|
||||||
staleanswersok = qctx->client->view->staleanswersenable;
|
|
||||||
break;
|
|
||||||
case dns_stale_answer_no:
|
|
||||||
staleanswersok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
staleanswersok = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (staleanswersok) {
|
|
||||||
qctx->client->query.dboptions |= DNS_DBFIND_STALEOK;
|
qctx->client->query.dboptions |= DNS_DBFIND_STALEOK;
|
||||||
if (qctx->client->query.fetch != NULL) {
|
if (qctx->client->query.fetch != NULL) {
|
||||||
dns_resolver_destroyfetch(&qctx->client->query.fetch);
|
dns_resolver_destroyfetch(&qctx->client->query.fetch);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
dns_db_detach(&qctx->db);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (staleanswersok);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
|
Reference in New Issue
Block a user