mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +00:00
Rename "staleonly"
The dboption DNS_DBFIND_STALEONLY caused confusion because it implies we are looking for stale data **only** and ignore any active RRsets in the cache. Rename it to DNS_DBFIND_STALETIMEOUT as it is more clear the option is related to a lookup due to "stale-answer-client-timeout". Rename other usages of "staleonly", instead use "lookup due to...". Also rename related function and variable names.
This commit is contained in:
@@ -259,12 +259,12 @@ struct dns_dbonupdatelistener {
|
||||
#define DNS_DBFIND_STALEENABLED 0x0800
|
||||
|
||||
/*
|
||||
* DNS_DBFIND_STALEONLY: This flag is used when we want stale data from the
|
||||
* DNS_DBFIND_STALETIMEOUT: This flag is used when we want stale data from the
|
||||
* database, but not due to a failure in resolution, it also doesn't require
|
||||
* stale-refresh-time window timer to be active. As long as there is stale
|
||||
* data available, it should be returned.
|
||||
*/
|
||||
#define DNS_DBFIND_STALEONLY 0x1000
|
||||
#define DNS_DBFIND_STALETIMEOUT 0x1000
|
||||
|
||||
/*
|
||||
* DNS_DBFIND_STALESTART: This flag is used to activate stale-refresh-time
|
||||
|
@@ -4562,11 +4562,11 @@ check_stale_header(dns_rbtnode_t *node, rdatasetheader_t *header,
|
||||
RDATASET_ATTR_SET(header,
|
||||
RDATASET_ATTR_STALE_WINDOW);
|
||||
return (false);
|
||||
} else if ((search->options & DNS_DBFIND_STALEONLY) !=
|
||||
0) {
|
||||
} else if ((search->options &
|
||||
DNS_DBFIND_STALETIMEOUT) != 0) {
|
||||
/*
|
||||
* We want stale RRset only, so we don't skip
|
||||
* it.
|
||||
* We want stale RRset due to timeout, so we
|
||||
* don't skip it.
|
||||
*/
|
||||
return (false);
|
||||
}
|
||||
|
@@ -139,8 +139,8 @@
|
||||
/*% Does the query allow stale data in the response? */
|
||||
#define QUERY_STALEOK(q) (((q)->attributes & NS_QUERYATTR_STALEOK) != 0)
|
||||
|
||||
/*% Does the query only wants to check for stale RRset? */
|
||||
#define QUERY_STALEONLY(q) (((q)->dboptions & DNS_DBFIND_STALEONLY) != 0)
|
||||
/*% Does the query wants to check for stale RRset due to a timeout? */
|
||||
#define QUERY_STALETIMEOUT(q) (((q)->dboptions & DNS_DBFIND_STALETIMEOUT) != 0)
|
||||
|
||||
/*% Does the rdataset 'r' have an attached 'No QNAME Proof'? */
|
||||
#define NOQNAME(r) (((r)->attributes & DNS_RDATASETATTR_NOQNAME) != 0)
|
||||
@@ -499,7 +499,7 @@ static void
|
||||
query_addauth(query_ctx_t *qctx);
|
||||
|
||||
static void
|
||||
query_clear_staleonly(ns_client_t *client);
|
||||
query_clear_stale(ns_client_t *client);
|
||||
|
||||
/*
|
||||
* Increment query statistics counters.
|
||||
@@ -5714,7 +5714,7 @@ query_refresh_rrset(query_ctx_t *orig_qctx) {
|
||||
REQUIRE(orig_qctx->client != NULL);
|
||||
|
||||
qctx_copy(orig_qctx, &qctx);
|
||||
qctx.client->query.dboptions &= ~(DNS_DBFIND_STALEONLY |
|
||||
qctx.client->query.dboptions &= ~(DNS_DBFIND_STALETIMEOUT |
|
||||
DNS_DBFIND_STALEOK |
|
||||
DNS_DBFIND_STALEENABLED);
|
||||
|
||||
@@ -5758,7 +5758,7 @@ query_lookup(query_ctx_t *qctx) {
|
||||
unsigned int dboptions;
|
||||
dns_ttl_t stale_refresh = 0;
|
||||
bool dbfind_stale = false;
|
||||
bool stale_only = false;
|
||||
bool stale_timeout = false;
|
||||
bool stale_found = false;
|
||||
bool refresh_rrset = false;
|
||||
bool stale_refresh_window = false;
|
||||
@@ -5795,7 +5795,7 @@ query_lookup(query_ctx_t *qctx) {
|
||||
* to refresh the RRset will still take place if an
|
||||
* active RRset is not available.
|
||||
*/
|
||||
qctx->client->query.dboptions |= DNS_DBFIND_STALEONLY;
|
||||
qctx->client->query.dboptions |= DNS_DBFIND_STALETIMEOUT;
|
||||
}
|
||||
|
||||
dboptions = qctx->client->query.dboptions;
|
||||
@@ -5849,7 +5849,7 @@ query_lookup(query_ctx_t *qctx) {
|
||||
(dboptions & DNS_DBFIND_STALEENABLED) != 0);
|
||||
|
||||
/*
|
||||
* If DNS_DBFIND_STALEONLY is set, a stale answer is requested.
|
||||
* If DNS_DBFIND_STALETIMEOUT is set, a stale answer is requested.
|
||||
* This can happen if 'stale-answer-client-timeout' is enabled.
|
||||
*
|
||||
* If 'stale-answer-client-timeout' is set to 0, and a stale
|
||||
@@ -5860,9 +5860,9 @@ query_lookup(query_ctx_t *qctx) {
|
||||
* answer is found, send it to the client. Don't try to refresh the
|
||||
* RRset because a fetch is already in progress.
|
||||
*/
|
||||
stale_only = ((dboptions & DNS_DBFIND_STALEONLY) != 0);
|
||||
stale_timeout = ((dboptions & DNS_DBFIND_STALETIMEOUT) != 0);
|
||||
|
||||
if (dbfind_stale || stale_refresh_window || stale_only) {
|
||||
if (dbfind_stale || stale_refresh_window || stale_timeout) {
|
||||
dns_name_format(qctx->client->query.qname, namebuf,
|
||||
sizeof(namebuf));
|
||||
|
||||
@@ -5911,7 +5911,7 @@ query_lookup(query_ctx_t *qctx) {
|
||||
QUERY_ERROR(qctx, DNS_R_SERVFAIL);
|
||||
return (ns_query_done(qctx));
|
||||
}
|
||||
} else if (stale_only) {
|
||||
} else if (stale_timeout) {
|
||||
qctx->client->query.attributes |= NS_QUERYATTR_STALEOK;
|
||||
qctx->rdataset->attributes |= DNS_RDATASETATTR_STALE_ADDED;
|
||||
|
||||
@@ -5926,7 +5926,7 @@ query_lookup(query_ctx_t *qctx) {
|
||||
dns_db_attach(qctx->client->view->cachedb,
|
||||
&qctx->db);
|
||||
qctx->client->query.dboptions &=
|
||||
~DNS_DBFIND_STALEONLY;
|
||||
~DNS_DBFIND_STALETIMEOUT;
|
||||
qctx->options &= ~DNS_GETDB_STALEFIRST;
|
||||
if (qctx->client->query.fetch != NULL) {
|
||||
dns_resolver_destroyfetch(
|
||||
@@ -6036,29 +6036,28 @@ message_clearrdataset(dns_message_t *msg, unsigned int attr) {
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear any rdatasets from the client's message that were added on a
|
||||
* stale-only lookup.
|
||||
* Clear any rdatasets from the client's message that were added on a lookup
|
||||
* due to a client timeout.
|
||||
*/
|
||||
static void
|
||||
query_clear_staleonly(ns_client_t *client) {
|
||||
query_clear_stale(ns_client_t *client) {
|
||||
message_clearrdataset(client->message, DNS_RDATASETATTR_STALE_ADDED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a new query context with the sole intent
|
||||
* of looking up for a stale RRset in cache.
|
||||
* If an entry is found, we mark the original query as
|
||||
* answered, in order to avoid answering the query twice,
|
||||
* when the original fetch finishes.
|
||||
* Create a new query context with the sole intent of looking up for a stale
|
||||
* RRset in cache. If an entry is found, we mark the original query as
|
||||
* answered, in order to avoid answering the query twice, when the original
|
||||
* fetch finishes.
|
||||
*/
|
||||
static inline void
|
||||
query_lookup_staleonly(ns_client_t *client) {
|
||||
query_lookup_stale(ns_client_t *client) {
|
||||
query_ctx_t qctx;
|
||||
|
||||
qctx_init(client, NULL, client->query.qtype, &qctx);
|
||||
dns_db_attach(client->view->cachedb, &qctx.db);
|
||||
client->query.attributes &= ~NS_QUERYATTR_RECURSIONOK;
|
||||
client->query.dboptions |= DNS_DBFIND_STALEONLY;
|
||||
client->query.dboptions |= DNS_DBFIND_STALETIMEOUT;
|
||||
client->nodetach = true;
|
||||
(void)query_lookup(&qctx);
|
||||
if (qctx.node != NULL) {
|
||||
@@ -6098,19 +6097,19 @@ fetch_callback(isc_task_t *task, isc_event_t *event) {
|
||||
CTRACE(ISC_LOG_DEBUG(3), "fetch_callback");
|
||||
|
||||
if (event->ev_type == DNS_EVENT_TRYSTALE) {
|
||||
query_lookup_staleonly(client);
|
||||
query_lookup_stale(client);
|
||||
isc_event_free(ISC_EVENT_PTR(&event));
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* We are resuming from recursion. Reset any attributes, options
|
||||
* that a stale-only lookup may have set.
|
||||
* that a lookup due to stale-answer-client-timeout may have set.
|
||||
*/
|
||||
if (client->view->cachedb != NULL && client->view->recursion) {
|
||||
client->query.attributes |= NS_QUERYATTR_RECURSIONOK;
|
||||
}
|
||||
client->query.dboptions &= ~DNS_DBFIND_STALEONLY;
|
||||
client->query.dboptions &= ~DNS_DBFIND_STALETIMEOUT;
|
||||
client->nodetach = false;
|
||||
|
||||
LOCK(&client->query.fetchlock);
|
||||
@@ -8002,12 +8001,12 @@ query_addanswer(query_ctx_t *qctx) {
|
||||
|
||||
/*
|
||||
* On normal lookups, clear any rdatasets that were added on a
|
||||
* staleonly lookup.
|
||||
* lookup due to stale-answer-client-timeout.
|
||||
*/
|
||||
if (QUERY_STALEOK(&qctx->client->query) &&
|
||||
!QUERY_STALEONLY(&qctx->client->query))
|
||||
!QUERY_STALETIMEOUT(&qctx->client->query))
|
||||
{
|
||||
query_clear_staleonly(qctx->client);
|
||||
query_clear_stale(qctx->client);
|
||||
/*
|
||||
* We can clear the attribute to prevent redundant clearing
|
||||
* in subsequent lookups.
|
||||
@@ -8049,7 +8048,7 @@ query_addanswer(query_ctx_t *qctx) {
|
||||
ns_client_putrdataset(qctx->client, &qctx->rdataset);
|
||||
} else {
|
||||
if (!qctx->is_zone && RECURSIONOK(qctx->client) &&
|
||||
!QUERY_STALEONLY(&qctx->client->query))
|
||||
!QUERY_STALETIMEOUT(&qctx->client->query))
|
||||
{
|
||||
query_prefetch(qctx->client, qctx->fname,
|
||||
qctx->rdataset);
|
||||
@@ -11662,7 +11661,7 @@ ns_query_done(query_ctx_t *qctx) {
|
||||
* resume when recursion ends.
|
||||
*/
|
||||
if (RECURSING(qctx->client) &&
|
||||
(!QUERY_STALEONLY(&qctx->client->query) ||
|
||||
(!QUERY_STALETIMEOUT(&qctx->client->query) ||
|
||||
((qctx->options & DNS_GETDB_STALEFIRST) != 0)))
|
||||
{
|
||||
return (qctx->result);
|
||||
|
Reference in New Issue
Block a user