* i.e. it starts with and optional _port label followed by a _dns label.
*/
+size_t
+dns_name_size(const dns_name_t *name);
+/*%<
+ * Return the amount of dynamically allocated memory associated with
+ * 'name' (which is 0 if 'name' is not dynamic).
+ *
+ * Requires:
+ * \li 'name' to be valid.
+ */
+
ISC_LANG_ENDDECLS
dns_name_invalidate(name);
}
+size_t
+dns_name_size(const dns_name_t *name) {
+ size_t size;
+
+ REQUIRE(DNS_NAME_VALID(name));
+
+ if (!name->attributes.dynamic) {
+ return (0);
+ }
+
+ size = name->length;
+ if (name->attributes.dynoffsets) {
+ size += name->labels;
+ }
+
+ return (size);
+}
+
isc_result_t
dns_name_digest(const dns_name_t *name, dns_digestfunc_t digest, void *arg) {
dns_name_t downname;
isc_rwlocktype_t *tlocktypep DNS__DB_FLARG) {
uint32_t locknum_start = qpdb->lru_sweep++ % qpdb->node_lock_count;
uint32_t locknum = locknum_start;
- /* Size of added data, possible node and possible ENT node. */
- size_t purgesize = rdataset_size(newheader) + 2 * sizeof(qpcnode_t);
- size_t purged = 0;
+ size_t purgesize, purged = 0;
isc_stdtime_t min_last_used = 0;
size_t max_passes = 8;
+ /*
+ * Maximum estimated size of the data being added: The size
+ * of the rdataset, plus a new QP database node and nodename,
+ * and a possible additional NSEC node and nodename. Also add
+ * a 12k margin for a possible QP-trie chunk allocation.
+ * (It's okay to overestimate, we want to get cache memory
+ * down quickly.)
+ */
+ purgesize = 2 * (sizeof(qpcnode_t) +
+ dns_name_size(&HEADERNODE(newheader)->name)) +
+ rdataset_size(newheader) + 12288;
again:
do {
isc_rwlocktype_t nlocktype = isc_rwlocktype_none;
#undef CHECK
#include <tests/dns.h>
+/* Set to true (or use -v option) for verbose output */
+static bool verbose = false;
+
/*
* Add to a cache DB 'db' an rdataset of type 'rtype' at a name
* <idx>.example.com. The rdataset would contain one data, and rdata_len is
/*
* Then try to add the same number of entries, each has very large data.
- * 'overmem purge' should keep the total cache size from not exceeding
+ * 'overmem purge' should keep the total cache size from exceeding
* the 'hiwater' mark too much. So we should be able to assume the
* cache size doesn't reach the "max".
*/
while (i-- > 0) {
overmempurge_addrdataset(db, now, i, 50054, 65535, false);
+ if (verbose) {
+ print_message("# inuse: %zd max: %zd\n",
+ isc_mem_inuse(mctx2), maxcache);
+ }
assert_true(isc_mem_inuse(mctx2) < maxcache);
}
*/
while (i-- > 0) {
overmempurge_addrdataset(db, now, i, 50054, 0, true);
+ if (verbose) {
+ print_message("# inuse: %zd max: %zd\n",
+ isc_mem_inuse(mctx2), maxcache);
+ }
assert_true(isc_mem_inuse(mctx2) < maxcache);
}