]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
When counting memory from closing a connection, count the dir conn too
authorNick Mathewson <nickm@torproject.org>
Mon, 18 Aug 2014 19:21:50 +0000 (15:21 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 18 Aug 2014 19:21:50 +0000 (15:21 -0400)
Fix part of bug 11972

changes/bug11792 [new file with mode: 0644]
src/or/circuitlist.c

diff --git a/changes/bug11792 b/changes/bug11792
new file mode 100644 (file)
index 0000000..1d38189
--- /dev/null
@@ -0,0 +1,5 @@
+  o Minor features (security, OOM):
+    - When closing an edge connection because we've run out of memory,
+      also count the amount of memory that any tunnelled directory
+      connection attached to that connection had consumed. Part of
+      ticket 11792.
\ No newline at end of file
index f3a83503efdb60095c59f563bb9944cf1a73f22f..9aeb3eb19ac888e0be7f5588650d3c1cd11d22e7 100644 (file)
@@ -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;