aboutsummaryrefslogtreecommitdiff
path: root/src/or/circuitlist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-01-12 12:26:45 -0500
committerNick Mathewson <nickm@torproject.org>2014-02-12 12:38:20 -0500
commitfd28754dd3dce0e00304825d531348414c0a354b (patch)
tree1b03a3d937444aa16732fdb8d6f9266706c6bd10 /src/or/circuitlist.c
parent79515917449c7e0d92f16db0d1e5af4a0370bbab (diff)
downloadtor-fd28754dd3dce0e00304825d531348414c0a354b.tar
tor-fd28754dd3dce0e00304825d531348414c0a354b.tar.gz
Actually release buffer freelists when handling OOM conditions.
Otherwise freeing buffers won't help for a little while.
Diffstat (limited to 'src/or/circuitlist.c')
-rw-r--r--src/or/circuitlist.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index 2e135416c..ffb5e0cd0 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -1533,6 +1533,17 @@ circuits_handle_oom(size_t current_allocation)
"MaxMemInQueues.)");
{
+ const size_t recovered = buf_shrink_freelists(1);
+ if (recovered >= current_allocation) {
+ log_warn(LD_BUG, "We somehow recovered more memory from freelists "
+ "than we thought we had allocated");
+ current_allocation = 0;
+ } else {
+ current_allocation -= recovered;
+ }
+ }
+
+ {
size_t mem_target = (size_t)(get_options()->MaxMemInQueues *
FRACTION_OF_DATA_TO_RETAIN_ON_OOM);
if (current_allocation <= mem_target)
@@ -1575,6 +1586,8 @@ circuits_handle_oom(size_t current_allocation)
} SMARTLIST_FOREACH_END(circ);
clean_cell_pool(); /* In case this helps. */
+ buf_shrink_freelists(1); /* This is necessary to actually release buffer
+ chunks. */
log_notice(LD_GENERAL, "Removed "U64_FORMAT" bytes by killing %d circuits.",
U64_PRINTF_ARG(mem_recovered),