diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-01-12 13:59:26 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-01-12 13:59:26 -0500 |
commit | c2e200cef8b910434d8b5d251597081935392377 (patch) | |
tree | 293dc48e46d39600302c771920a9369b27d723dd /src/or/relay.c | |
parent | b0c32106b3559b4ee9fabfb1a49e2e328c850305 (diff) | |
parent | 3033ba9f5ec8eb4dea3e6778f6d7546cacf7ae57 (diff) | |
download | tor-c2e200cef8b910434d8b5d251597081935392377.tar.gz tor-c2e200cef8b910434d8b5d251597081935392377.zip |
Merge branch 'bug13806_squashed'
Conflicts:
src/or/relay.c
Diffstat (limited to 'src/or/relay.c')
-rw-r--r-- | src/or/relay.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/or/relay.c b/src/or/relay.c index 2d11096309..28211ff8ff 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -2447,12 +2447,24 @@ cell_queues_check_size(void) size_t alloc = cell_queues_get_total_allocation(); alloc += buf_get_total_allocation(); alloc += tor_zlib_get_total_allocation(); + const size_t rend_cache_total = rend_cache_get_total_allocation(); + alloc += rend_cache_total; if (alloc >= get_options()->MaxMemInQueues_low_threshold) { last_time_under_memory_pressure = approx_time(); - if (alloc >= get_options()->MaxMemInQueues) { - circuits_handle_oom(alloc); - return 1; + 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%. + */ + if (rend_cache_total > get_options()->MaxMemInQueues / 5) { + const size_t bytes_to_remove = + rend_cache_total - (get_options()->MaxMemInQueues / 10); + rend_cache_clean_v2_descs_as_dir(time(NULL), bytes_to_remove); + alloc -= rend_cache_total; + alloc += rend_cache_get_total_allocation(); } + circuits_handle_oom(alloc); + return 1; + } } return 0; } |