diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-08-18 15:21:50 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-08-18 15:21:50 -0400 |
commit | ec59167cae1f5b3057ed722857d78ec78239e991 (patch) | |
tree | 9c0799c962f1f562bb0fcee4be1791b2bdcca2c4 /src/or/circuitlist.c | |
parent | 2937de21803174e14873f68b34ba8a6c62285c45 (diff) | |
download | tor-ec59167cae1f5b3057ed722857d78ec78239e991.tar.gz tor-ec59167cae1f5b3057ed722857d78ec78239e991.zip |
When counting memory from closing a connection, count the dir conn too
Fix part of bug 11972
Diffstat (limited to 'src/or/circuitlist.c')
-rw-r--r-- | src/or/circuitlist.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index f3a83503ef..9aeb3eb19a 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -1799,6 +1799,21 @@ marked_circuit_free_cells(circuit_t *circ) cell_queue_clear(& TO_OR_CIRCUIT(circ)->p_chan_cells); } +static size_t +marked_circuit_single_conn_free_bytes(connection_t *conn) +{ + size_t result = 0; + if (conn->inbuf) { + result += buf_allocation(conn->inbuf); + buf_clear(conn->inbuf); + } + if (conn->outbuf) { + result += buf_allocation(conn->outbuf); + buf_clear(conn->outbuf); + } + return result; +} + /** Aggressively free buffer contents on all the buffers of all streams in the * list starting at <b>stream</b>. Return the number of bytes recovered. */ static size_t @@ -1807,13 +1822,9 @@ marked_circuit_streams_free_bytes(edge_connection_t *stream) size_t result = 0; for ( ; stream; stream = stream->next_stream) { connection_t *conn = TO_CONN(stream); - if (conn->inbuf) { - result += buf_allocation(conn->inbuf); - buf_clear(conn->inbuf); - } - if (conn->outbuf) { - result += buf_allocation(conn->outbuf); - buf_clear(conn->outbuf); + result += marked_circuit_single_conn_free_bytes(conn); + if (conn->linked_conn) { + result += marked_circuit_single_conn_free_bytes(conn->linked_conn); } } return result; |