]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Merge remote-tracking branch 'public/bug10169_024' into bug10169_025_v2
authorNick Mathewson <nickm@torproject.org>
Wed, 12 Feb 2014 17:44:58 +0000 (12:44 -0500)
committerNick Mathewson <nickm@torproject.org>
Wed, 12 Feb 2014 17:44:58 +0000 (12:44 -0500)
Conflicts:
src/or/circuitlist.c

1  2 
doc/tor.1.txt
src/or/buffers.c
src/or/buffers.h
src/or/circuitlist.c
src/or/config.c
src/or/or.h
src/or/relay.c

diff --cc doc/tor.1.txt
Simple merge
Simple merge
Simple merge
index 94748963677c917d878d8b8d7dd15a0f8cac2ea7,3081035abba236d091914283410240f93a50ad5d..eb652301edfbc8b6a3776833bd9efeba2fb8bfc5
@@@ -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. */
diff --cc src/or/config.c
Simple merge
diff --cc src/or/or.h
Simple merge
diff --cc src/or/relay.c
Simple merge