[or-cvs] [tor/master 2/2] Correctly report written bytes on linked connections.

nickm at torproject.org nickm at torproject.org
Wed Aug 18 14:02:57 UTC 2010


Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Mon, 9 Aug 2010 15:25:09 +0200
Subject: Correctly report written bytes on linked connections.
Commit: 58b6195455bcb173d260558e84e642c52d344c2f

---
 changes/bugfoundin1790 |    4 ++++
 src/or/connection.c    |    8 ++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)
 create mode 100644 changes/bugfoundin1790

diff --git a/changes/bugfoundin1790 b/changes/bugfoundin1790
new file mode 100644
index 0000000..0a18fe1
--- /dev/null
+++ b/changes/bugfoundin1790
@@ -0,0 +1,4 @@
+  o Minor bugfixes:
+    - Correctly report written bytes on linked connections. Found while
+      implementing 1790. Bugfix on 0.2.2.4-alpha.
+
diff --git a/src/or/connection.c b/src/or/connection.c
index 5438cf7..99ce7ff 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -2409,8 +2409,12 @@ loop_again:
     connection_t *linked = conn->linked_conn;
 
     if (n_read) {
-      /* Probably a no-op, but hey. */
-      connection_buckets_decrement(linked, approx_time(), n_read, 0);
+      /* Probably a no-op, since linked conns typically don't count for
+       * bandwidth rate limiting. But do it anyway so we can keep stats
+       * accurately. Note that since we read the bytes from conn, and
+       * we're writing the bytes onto the linked connection, we count
+       * these as <i>written</i> bytes. */
+      connection_buckets_decrement(linked, approx_time(), 0, n_read);
 
       if (connection_flushed_some(linked) < 0)
         connection_mark_for_close(linked);
-- 
1.7.1



More information about the tor-commits mailing list