summaryrefslogtreecommitdiff
path: root/src/or/relay.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-02-02 15:00:35 -0500
committerNick Mathewson <nickm@torproject.org>2018-02-02 15:00:35 -0500
commiteafa252b26ecf83a8a48e7e19a3315e1d2983186 (patch)
tree138718b77c1f7de05512f2dd6f674dd000baad05 /src/or/relay.c
parent9e48338a12fd1fef840dc49c702b4a628af67cc0 (diff)
parent475218c108ad84aa302f0daec013faab9ff778f2 (diff)
downloadtor-eafa252b26ecf83a8a48e7e19a3315e1d2983186.tar.gz
tor-eafa252b26ecf83a8a48e7e19a3315e1d2983186.zip
Merge remote-tracking branch 'dgoulet/ticket24902_029_05'
Diffstat (limited to 'src/or/relay.c')
-rw-r--r--src/or/relay.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/or/relay.c b/src/or/relay.c
index b1b99526df..506b7eccb3 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -2613,21 +2613,31 @@ static time_t last_time_under_memory_pressure = 0;
STATIC int
cell_queues_check_size(void)
{
+ time_t now = time(NULL);
size_t alloc = cell_queues_get_total_allocation();
alloc += buf_get_total_allocation();
alloc += tor_compress_get_total_allocation();
const size_t rend_cache_total = rend_cache_get_total_allocation();
alloc += rend_cache_total;
+ const size_t geoip_client_cache_total =
+ geoip_client_cache_total_allocation();
+ alloc += geoip_client_cache_total;
if (alloc >= get_options()->MaxMemInQueues_low_threshold) {
last_time_under_memory_pressure = approx_time();
if (alloc >= get_options()->MaxMemInQueues) {
/* If we're spending over 20% of the memory limit on hidden service
- * descriptors, free them until we're down to 10%.
- */
+ * descriptors, free them until we're down to 10%. Do the same for geoip
+ * client cache. */
if (rend_cache_total > get_options()->MaxMemInQueues / 5) {
const size_t bytes_to_remove =
rend_cache_total - (size_t)(get_options()->MaxMemInQueues / 10);
- alloc -= hs_cache_handle_oom(time(NULL), bytes_to_remove);
+ alloc -= hs_cache_handle_oom(now, bytes_to_remove);
+ }
+ if (geoip_client_cache_total > get_options()->MaxMemInQueues / 5) {
+ const size_t bytes_to_remove =
+ geoip_client_cache_total -
+ (size_t)(get_options()->MaxMemInQueues / 10);
+ alloc -= geoip_client_cache_handle_oom(now, bytes_to_remove);
}
circuits_handle_oom(alloc);
return 1;