diff options
author | Neel Chauhan <neel@neelc.org> | 2018-07-16 17:36:22 -0400 |
---|---|---|
committer | Neel Chauhan <neel@neelc.org> | 2018-07-17 09:19:27 -0400 |
commit | 32db806dfa85b016a2d56d0d5248f17c34b690c4 (patch) | |
tree | c503d6ffcd6e160fb4f9deb7e8c6ddbe95d2f0dc /src/core | |
parent | d807ca1b014e27a2808959dba1a37a0c1d53240f (diff) | |
download | tor-32db806dfa85b016a2d56d0d5248f17c34b690c4.tar.gz tor-32db806dfa85b016a2d56d0d5248f17c34b690c4.zip |
Teach the OOM handler about the DNS cache
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/or/relay.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/core/or/relay.c b/src/core/or/relay.c index 32bb69d25f..62a4bca848 100644 --- a/src/core/or/relay.c +++ b/src/core/or/relay.c @@ -64,6 +64,7 @@ #include "lib/crypt_ops/crypto_rand.h" #include "lib/crypt_ops/crypto_util.h" #include "feature/dircache/directory.h" +#include "feature/relay/dns.h" #include "feature/stats/geoip.h" #include "feature/hs/hs_cache.h" #include "core/mainloop/main.h" @@ -2537,6 +2538,7 @@ cell_queues_check_size(void) const size_t geoip_client_cache_total = geoip_client_cache_total_allocation(); alloc += geoip_client_cache_total; + const size_t dns_cache_total = dns_cache_total_allocation(); if (alloc >= get_options()->MaxMemInQueues_low_threshold) { last_time_under_memory_pressure = approx_time(); if (alloc >= get_options()->MaxMemInQueues) { @@ -2554,6 +2556,11 @@ cell_queues_check_size(void) (size_t)(get_options()->MaxMemInQueues / 10); alloc -= geoip_client_cache_handle_oom(now, bytes_to_remove); } + if (dns_cache_total > get_options()->MaxMemInQueues / 5) { + const size_t bytes_to_remove = + dns_cache_total - (size_t)(get_options()->MaxMemInQueues / 10); + alloc -= dns_cache_handle_oom(now, bytes_to_remove); + } circuits_handle_oom(alloc); return 1; } |