mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 16:15:27 +00:00
Check 'stale-refresh-time' when sharing cache between views
This commit ensures that, along with previous restrictions, a cache is shareable between views only if their 'stale-refresh-time' value are equal.
This commit is contained in:
@@ -1869,7 +1869,7 @@ cache_reusable(dns_view_t *originview, dns_view_t *view,
|
|||||||
static bool
|
static bool
|
||||||
cache_sharable(dns_view_t *originview, dns_view_t *view,
|
cache_sharable(dns_view_t *originview, dns_view_t *view,
|
||||||
bool new_zero_no_soattl, uint64_t new_max_cache_size,
|
bool new_zero_no_soattl, uint64_t new_max_cache_size,
|
||||||
uint32_t new_stale_ttl) {
|
uint32_t new_stale_ttl, uint32_t new_stale_refresh_time) {
|
||||||
/*
|
/*
|
||||||
* If the cache cannot even reused for the same view, it cannot be
|
* If the cache cannot even reused for the same view, it cannot be
|
||||||
* shared with other views.
|
* shared with other views.
|
||||||
@@ -1883,6 +1883,7 @@ cache_sharable(dns_view_t *originview, dns_view_t *view,
|
|||||||
* the sharing views.
|
* the sharing views.
|
||||||
*/
|
*/
|
||||||
if (dns_cache_getservestalettl(originview->cache) != new_stale_ttl ||
|
if (dns_cache_getservestalettl(originview->cache) != new_stale_ttl ||
|
||||||
|
dns_cache_getservestalerefresh(originview->cache) != new_stale_refresh_time ||
|
||||||
dns_cache_getcachesize(originview->cache) != new_max_cache_size)
|
dns_cache_getcachesize(originview->cache) != new_max_cache_size)
|
||||||
{
|
{
|
||||||
return (false);
|
return (false);
|
||||||
@@ -4435,7 +4436,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
|
|||||||
nsc = cachelist_find(cachelist, cachename, view->rdclass);
|
nsc = cachelist_find(cachelist, cachename, view->rdclass);
|
||||||
if (nsc != NULL) {
|
if (nsc != NULL) {
|
||||||
if (!cache_sharable(nsc->primaryview, view, zero_no_soattl,
|
if (!cache_sharable(nsc->primaryview, view, zero_no_soattl,
|
||||||
max_cache_size, max_stale_ttl))
|
max_cache_size, max_stale_ttl, stale_refresh_time))
|
||||||
{
|
{
|
||||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
||||||
|
@@ -142,6 +142,7 @@ struct dns_cache {
|
|||||||
char **db_argv;
|
char **db_argv;
|
||||||
size_t size;
|
size_t size;
|
||||||
dns_ttl_t serve_stale_ttl;
|
dns_ttl_t serve_stale_ttl;
|
||||||
|
dns_ttl_t serve_stale_refresh;
|
||||||
isc_stats_t *stats;
|
isc_stats_t *stats;
|
||||||
|
|
||||||
/* Locked by 'filelock'. */
|
/* Locked by 'filelock'. */
|
||||||
@@ -1000,12 +1001,27 @@ dns_cache_getservestalettl(dns_cache_t *cache) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dns_cache_setservestalerefresh(dns_cache_t *cache, uint32_t interval) {
|
dns_cache_setservestalerefresh(dns_cache_t *cache, dns_ttl_t interval) {
|
||||||
REQUIRE(VALID_CACHE(cache));
|
REQUIRE(VALID_CACHE(cache));
|
||||||
|
|
||||||
|
LOCK(&cache->lock);
|
||||||
|
cache->serve_stale_refresh = interval;
|
||||||
|
UNLOCK(&cache->lock);
|
||||||
|
|
||||||
(void)dns_db_setservestalerefresh(cache->db, interval);
|
(void)dns_db_setservestalerefresh(cache->db, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dns_ttl_t
|
||||||
|
dns_cache_getservestalerefresh(dns_cache_t *cache) {
|
||||||
|
isc_result_t result;
|
||||||
|
dns_ttl_t interval;
|
||||||
|
|
||||||
|
REQUIRE(VALID_CACHE(cache));
|
||||||
|
|
||||||
|
result = dns_db_getservestalerefresh(cache->db, &interval);
|
||||||
|
return (result == ISC_R_SUCCESS ? interval : 0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The cleaner task is shutting down; do the necessary cleanup.
|
* The cleaner task is shutting down; do the necessary cleanup.
|
||||||
*/
|
*/
|
||||||
|
@@ -256,7 +256,7 @@ dns_cache_getservestalettl(dns_cache_t *cache);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
dns_cache_setservestalerefresh(dns_cache_t *cache, uint32_t interval);
|
dns_cache_setservestalerefresh(dns_cache_t *cache, dns_ttl_t interval);
|
||||||
/*%<
|
/*%<
|
||||||
* Sets the length of time to wait before attempting to refresh a rrset
|
* Sets the length of time to wait before attempting to refresh a rrset
|
||||||
* if a previous attempt in doing so has failed.
|
* if a previous attempt in doing so has failed.
|
||||||
@@ -267,6 +267,16 @@ dns_cache_setservestalerefresh(dns_cache_t *cache, uint32_t interval);
|
|||||||
*\li 'cache' to be valid.
|
*\li 'cache' to be valid.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
dns_ttl_t
|
||||||
|
dns_cache_getservestalerefresh(dns_cache_t *cache);
|
||||||
|
/*%<
|
||||||
|
* Gets the 'stale-refresh-time' value, set by a previous call to
|
||||||
|
* 'dns_cache_setservestalerefresh'.
|
||||||
|
*
|
||||||
|
* Requires:
|
||||||
|
*\li 'cache' to be valid.
|
||||||
|
*/
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
dns_cache_flush(dns_cache_t *cache);
|
dns_cache_flush(dns_cache_t *cache);
|
||||||
/*%<
|
/*%<
|
||||||
|
Reference in New Issue
Block a user