diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-02-12 12:39:15 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-02-12 12:39:15 -0500 |
commit | 05d8111eedee9e11e4bb1c42e93ae2fc168d52ec (patch) | |
tree | 6a77e7b0e087d594adce42693bc369478cd01d6f /src/or/circuitlist.c | |
parent | 5c45a333c3cdfc4c7a817425a1c3ae88085c389b (diff) | |
parent | fd28754dd3dce0e00304825d531348414c0a354b (diff) | |
download | tor-05d8111eedee9e11e4bb1c42e93ae2fc168d52ec.tar.gz tor-05d8111eedee9e11e4bb1c42e93ae2fc168d52ec.zip |
Merge remote-tracking branch 'public/bug10169_023' into bug10169_024
Diffstat (limited to 'src/or/circuitlist.c')
-rw-r--r-- | src/or/circuitlist.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index 8a581e6501..3081035abb 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -1675,6 +1675,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) @@ -1717,6 +1728,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), |