[tor-commits] [tor/master] Merge remote-tracking branch 'public/bug10169_024' into bug10169_025_v2
nickm at torproject.org
nickm at torproject.org
Tue Mar 4 16:04:42 UTC 2014
commit 87fb1e324c1b3214765c46bec3d9ec6adc3fa83d
Merge: 10d4d3e 05d8111
Author: Nick Mathewson <nickm at torproject.org>
Date: Wed Feb 12 12:44:58 2014 -0500
Merge remote-tracking branch 'public/bug10169_024' into bug10169_025_v2
Conflicts:
src/or/circuitlist.c
changes/bug10169 | 4 ++
changes/bug9686 | 3 +
doc/tor.1.txt | 10 ++--
src/or/buffers.c | 59 ++++++++++++++++++--
src/or/buffers.h | 5 +-
src/or/circuitlist.c | 151 +++++++++++++++++++++++++++++++++++++++++---------
src/or/config.c | 9 +--
src/or/or.h | 8 ++-
src/or/relay.c | 3 +-
9 files changed, 207 insertions(+), 45 deletions(-)
diff --cc src/or/circuitlist.c
index 9474896,3081035..eb65230
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@@ -1612,8 -1513,40 +1612,40 @@@ marked_circuit_free_cells(circuit_t *ci
cell_queue_clear(& TO_OR_CIRCUIT(circ)->p_chan_cells);
}
+ /** 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
+ 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);
+ }
+ }
+ return result;
+ }
+
+ /** Aggressively free buffer contents on all the buffers of all streams on
+ * circuit <b>c</b>. Return the number of bytes recovered. */
+ static size_t
+ marked_circuit_free_stream_bytes(circuit_t *c)
+ {
+ if (CIRCUIT_IS_ORIGIN(c)) {
+ return marked_circuit_streams_free_bytes(TO_ORIGIN_CIRCUIT(c)->p_streams);
+ } else {
+ return marked_circuit_streams_free_bytes(TO_OR_CIRCUIT(c)->n_streams);
+ }
+ }
+
/** Return the number of cells used by the circuit <b>c</b>'s cell queues. */
-static size_t
+STATIC size_t
n_cells_in_circ_queues(const circuit_t *c)
{
size_t n = c->n_chan_cells.n;
@@@ -1700,17 -1691,17 +1792,17 @@@ circuits_handle_oom(size_t current_allo
if (current_allocation <= mem_target)
return;
mem_to_recover = current_allocation - mem_target;
- n_cells_to_remove = CEIL_DIV(mem_to_recover, packed_cell_mem_cost());
}
+ tor_gettimeofday_cached(&now);
+ now_ms = (uint32_t)tv_to_msec(&now);
+
/* This algorithm itself assumes that you've got enough memory slack
* to actually run it. */
- TOR_LIST_FOREACH(circ, &global_circuitlist, head)
- for (circ = global_circuitlist; circ; circ = circ->next) {
++ TOR_LIST_FOREACH(circ, &global_circuitlist, head) {
+ circ->age_tmp = circuit_max_queued_item_age(circ, now_ms);
smartlist_add(circlist, circ);
-
- /* Set circcomp_now_tmp so that the sort can work. */
- tor_gettimeofday_cached(&now);
- circcomp_now_tmp = (uint32_t)tv_to_msec(&now);
+ }
/* This is O(n log n); there are faster algorithms we could use instead.
* Let's hope this doesn't happen enough to be in the critical path. */
More information about the tor-commits
mailing list