mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-03 13:59:27 -04:00
Added dns_view_staleanswerenabled() function
Since it takes a couple lines of code to check whether stale answers are enabled for a given view, code was extracted out to a proper function.
This commit is contained in:
parent
49c40827f6
commit
74840ec50b
4 changed files with 35 additions and 13 deletions
|
|
@ -1343,6 +1343,15 @@ dns_view_setviewrevert(dns_view_t *view);
|
|||
*\li 'view' to be valid.
|
||||
*/
|
||||
|
||||
bool
|
||||
dns_view_staleanswerenabled(dns_view_t *view);
|
||||
/*%<
|
||||
* Check if stale answers are enabled for this view.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'view' to be valid.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* DNS_VIEW_H */
|
||||
|
|
|
|||
|
|
@ -2518,3 +2518,25 @@ dns_view_setviewrevert(dns_view_t *view) {
|
|||
dns_zt_setviewrevert(zonetable);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
dns_view_staleanswerenabled(dns_view_t *view) {
|
||||
uint32_t stale_ttl = 0;
|
||||
bool result = false;
|
||||
|
||||
REQUIRE(DNS_VIEW_VALID(view));
|
||||
|
||||
if (dns_db_getservestalettl(view->cachedb, &stale_ttl) != ISC_R_SUCCESS)
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
if (stale_ttl > 0) {
|
||||
if (view->staleanswersok == dns_stale_answer_yes) {
|
||||
result = true;
|
||||
} else if (view->staleanswersok == dns_stale_answer_conf) {
|
||||
result = view->staleanswersenable;
|
||||
}
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1147,6 +1147,7 @@ dns_view_setrootdelonly
|
|||
dns_view_setviewcommit
|
||||
dns_view_setviewrevert
|
||||
dns_view_simplefind
|
||||
dns_view_staleanswerenabled
|
||||
dns_view_thaw
|
||||
dns_view_untrust
|
||||
dns_view_weakattach
|
||||
|
|
|
|||
|
|
@ -5581,7 +5581,6 @@ query_lookup(query_ctx_t *qctx) {
|
|||
dns_clientinfo_t ci;
|
||||
dns_name_t *rpzqname = NULL;
|
||||
unsigned int dboptions;
|
||||
dns_ttl_t stale_ttl = 0;
|
||||
dns_ttl_t stale_refresh = 0;
|
||||
bool dbfind_stale = false;
|
||||
|
||||
|
|
@ -5644,18 +5643,9 @@ query_lookup(query_ctx_t *qctx) {
|
|||
|
||||
(void)dns_db_getservestalerefresh(qctx->client->view->cachedb,
|
||||
&stale_refresh);
|
||||
(void)dns_db_getservestalettl(qctx->client->view->cachedb, &stale_ttl);
|
||||
if (stale_refresh > 0) {
|
||||
if (qctx->client->view->staleanswersok == dns_stale_answer_yes)
|
||||
{
|
||||
dboptions |= DNS_DBFIND_STALEENABLED;
|
||||
} else if (qctx->client->view->staleanswersok ==
|
||||
dns_stale_answer_conf) {
|
||||
if (qctx->client->view->staleanswersenable &&
|
||||
stale_ttl > 0) {
|
||||
dboptions |= DNS_DBFIND_STALEENABLED;
|
||||
}
|
||||
}
|
||||
if (stale_refresh > 0 &&
|
||||
dns_view_staleanswerenabled(qctx->client->view)) {
|
||||
dboptions |= DNS_DBFIND_STALEENABLED;
|
||||
}
|
||||
|
||||
result = dns_db_findext(qctx->db, rpzqname, qctx->version, qctx->type,
|
||||
|
|
|
|||
Loading…
Reference in a new issue