static size_t
sanitized_max_cache_size(const cfg_obj_t *obj, uint64_t value) {
- if (value >= DNS_CACHE_MINSIZE && value <= SIZE_MAX) {
- return value;
- }
-
if (value > SIZE_MAX) {
cfg_obj_log(obj, ISC_LOG_WARNING,
"'max-cache-size %" PRIu64 "' "
if (value < DNS_CACHE_MINSIZE) {
cfg_obj_log(obj, ISC_LOG_WARNING,
- "'max-cache-size' can't be less than %" PRIu64 "; "
- "setting 'max-cache-size' to the minimum value",
- DNS_CACHE_MINSIZE);
+ "'max-cache-size %" PRIu64 "' "
+ "is too small; setting to %" PRIu64,
+ value, DNS_CACHE_MINSIZE);
return DNS_CACHE_MINSIZE;
}
- UNREACHABLE();
+ return value;
}
static size_t
default value of that option (90% of physical memory for each
individual cache) may lead to memory exhaustion over time.
- .. note::
+ .. warning::
- :any:`max-cache-size` does not work reliably for a maximum
- amount of memory of 256 MB or lower.
+ Setting :any:`max-cache-size` to a value lower than 256 MB is
+ permitted but not recommended; LRU-only cache eviction may cause
+ excessive churn under load.
Upon startup and reconfiguration, caches with a limited size
preallocate a small amount of memory (less than 1% of
internal cache structures.
On systems where detection of the amount of physical memory is not
- supported, the :iscman:`named` will fail to start.
+ supported, :iscman:`named` will fall back to the minimum value (2 MB).
.. note::
#define DNS_ADBADDRINFO_MAGIC ISC_MAGIC('a', 'd', 'A', 'I')
#define DNS_ADBADDRINFO_VALID(x) ISC_MAGIC_VALID(x, DNS_ADBADDRINFO_MAGIC)
-#define DNS_ADB_MINADBSIZE (1024U * 1024U) /*%< 1 Megabyte */
+#define DNS_ADB_MINADBSIZE UINT64_C(1024 * 1024) /*%< 1 MB */
/***
*** TYPES
* DNS_CACHE_MINSIZE is how many bytes is the floor for
* dns_cache_setcachesize().
*/
-#define DNS_CACHE_MINSIZE UINT64_C(2097152) /*%< Bytes. 2097152 = 2 MB */
+#define DNS_CACHE_MINSIZE UINT64_C(2 * 1024 * 1024) /*%< Bytes. 2 MB */
/***
*** Functions