aboutsummaryrefslogtreecommitdiff
path: root/src/core/or/circuitlist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-09-18 16:40:30 -0400
committerNick Mathewson <nickm@torproject.org>2018-09-18 16:40:30 -0400
commit88a93ccc7bdae432e07eac1e9b6ad4224f370b91 (patch)
treed2ec68d3680da966d94ef7f40722427f56576d44 /src/core/or/circuitlist.c
parent50367d06f2ae1a06e6553a8925b5aded7f610082 (diff)
parenteaeb4c1082b7133ec96c4f570818b2a8f4880141 (diff)
downloadtor-88a93ccc7bdae432e07eac1e9b6ad4224f370b91.tar.gz
tor-88a93ccc7bdae432e07eac1e9b6ad4224f370b91.zip
Merge branch 'ticket27686_035'
Diffstat (limited to 'src/core/or/circuitlist.c')
-rw-r--r--src/core/or/circuitlist.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/core/or/circuitlist.c b/src/core/or/circuitlist.c
index 7cf5e3445a..088540dea2 100644
--- a/src/core/or/circuitlist.c
+++ b/src/core/or/circuitlist.c
@@ -1081,9 +1081,9 @@ circuit_free_(circuit_t *circ)
circuit_remove_from_origin_circuit_list(ocirc);
if (ocirc->half_streams) {
- SMARTLIST_FOREACH_BEGIN(ocirc->half_streams, half_edge_t*,
+ SMARTLIST_FOREACH_BEGIN(ocirc->half_streams, half_edge_t *,
half_conn) {
- tor_free(half_conn);
+ half_edge_free(half_conn);
} SMARTLIST_FOREACH_END(half_conn);
smartlist_free(ocirc->half_streams);
}
@@ -2421,6 +2421,20 @@ n_cells_in_circ_queues(const circuit_t *c)
return n;
}
+/** Return the number of bytes allocated for <b>c</c>'s half-open streams. */
+static size_t
+circuit_alloc_in_half_streams(const circuit_t *c)
+{
+ if (! CIRCUIT_IS_ORIGIN(c)) {
+ return 0;
+ }
+ const origin_circuit_t *ocirc = CONST_TO_ORIGIN_CIRCUIT(c);
+ if (ocirc->half_streams)
+ return smartlist_len(ocirc->half_streams) * sizeof(half_edge_t);
+ else
+ return 0;
+}
+
/**
* Return the age of the oldest cell queued on <b>c</b>, in timestamp units.
* Return 0 if there are no cells queued on c. Requires that <b>now</b> be
@@ -2655,6 +2669,7 @@ circuits_handle_oom(size_t current_allocation)
/* Now, kill the circuit. */
n = n_cells_in_circ_queues(circ);
+ const size_t half_stream_alloc = circuit_alloc_in_half_streams(circ);
if (! circ->marked_for_close) {
circuit_mark_for_close(circ, END_CIRC_REASON_RESOURCELIMIT);
}
@@ -2664,6 +2679,7 @@ circuits_handle_oom(size_t current_allocation)
++n_circuits_killed;
mem_recovered += n * packed_cell_mem_cost();
+ mem_recovered += half_stream_alloc;
mem_recovered += freed;
if (mem_recovered >= mem_to_recover)