]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Merge branch 'bug13806_squashed'
authorNick Mathewson <nickm@torproject.org>
Mon, 12 Jan 2015 18:59:26 +0000 (13:59 -0500)
committerNick Mathewson <nickm@torproject.org>
Mon, 12 Jan 2015 18:59:26 +0000 (13:59 -0500)
Conflicts:
src/or/relay.c

1  2 
src/or/main.c
src/or/or.h
src/or/relay.c
src/or/rendcommon.c
src/or/rendcommon.h

diff --cc src/or/main.c
Simple merge
diff --cc src/or/or.h
Simple merge
diff --cc src/or/relay.c
index 2d11096309da2d5b23286bd14cb9e4c87db67edf,50070b7d903eae74a51a3c90f1c01d123b601cff..28211ff8ffbf08c232dc067bf2904bdcf4a024c4
@@@ -2447,13 -2441,22 +2447,25 @@@ cell_queues_check_size(void
    size_t alloc = cell_queues_get_total_allocation();
    alloc += buf_get_total_allocation();
    alloc += tor_zlib_get_total_allocation();
-     if (alloc >= get_options()->MaxMemInQueues) {
-       circuits_handle_oom(alloc);
-       return 1;
+   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) {
+     /* 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;
  }
  
Simple merge
Simple merge