summaryrefslogtreecommitdiff
path: root/src/feature/relay/dns.c
diff options
context:
space:
mode:
authorNeel Chauhan <neel@neelc.org>2018-07-16 17:19:53 -0400
committerNeel Chauhan <neel@neelc.org>2018-07-16 17:19:53 -0400
commitd807ca1b014e27a2808959dba1a37a0c1d53240f (patch)
treee2d4233dd14ced6f420f6e1944be48a4412a3426 /src/feature/relay/dns.c
parent5aaea38d889ae558ea0e9b01b4c5b58f3935b542 (diff)
downloadtor-d807ca1b014e27a2808959dba1a37a0c1d53240f.tar.gz
tor-d807ca1b014e27a2808959dba1a37a0c1d53240f.zip
Add and use dns_cache_total_allocation()
Diffstat (limited to 'src/feature/relay/dns.c')
-rw-r--r--src/feature/relay/dns.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/feature/relay/dns.c b/src/feature/relay/dns.c
index f4e39dfd3d..8a49829d55 100644
--- a/src/feature/relay/dns.c
+++ b/src/feature/relay/dns.c
@@ -2076,14 +2076,21 @@ dns_cache_entry_count(void)
return HT_SIZE(&cache_root);
}
+/* Return the total size in bytes of the DNS cache. */
+size_t
+dns_cache_total_allocation(void)
+{
+ return sizeof(struct cached_resolve_t) * dns_cache_entry_count() +
+ HT_MEM_USAGE(&cache_root);
+}
+
/** Log memory information about our internal DNS cache at level 'severity'. */
void
dump_dns_mem_usage(int severity)
{
/* This should never be larger than INT_MAX. */
int hash_count = dns_cache_entry_count();
- size_t hash_mem = sizeof(struct cached_resolve_t) * hash_count;
- hash_mem += HT_MEM_USAGE(&cache_root);
+ size_t hash_mem = dns_cache_total_allocation();
/* Print out the count and estimated size of our &cache_root. It undercounts
hostnames in cached reverse resolves.