aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection.c
diff options
context:
space:
mode:
authorKarsten Loesing <karsten.loesing@gmx.net>2013-02-06 14:15:32 +0100
committerKarsten Loesing <karsten.loesing@gmx.net>2013-05-16 13:48:35 +0200
commit8d1f78c556abb570bb80ea84261c954d9746cf33 (patch)
treeab3888a02792bc7a7e04989e7f8035c747f43e93 /src/or/connection.c
parente54d664f7bb1205162c1df3495f8ebc30c23d867 (diff)
downloadtor-8d1f78c556abb570bb80ea84261c954d9746cf33.tar.gz
tor-8d1f78c556abb570bb80ea84261c954d9746cf33.zip
Add new CONN_BW event.
Jointly authored with Rob Jansen <jansen@cs.umn.edu>.
Diffstat (limited to 'src/or/connection.c')
-rw-r--r--src/or/connection.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 87fa79970e..81b499160a 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -3148,6 +3148,18 @@ connection_read_to_buf(connection_t *conn, ssize_t *max_to_read,
else
edge_conn->n_read = UINT32_MAX;
}
+
+ /* In TestingTorNetwork mode, update conn->n_read for OR/DIR/EXIT
+ * connections, checking for overflow. */
+ if (get_options()->TestingTorNetwork &&
+ (conn->type == CONN_TYPE_OR ||
+ conn->type == CONN_TYPE_DIR ||
+ conn->type == CONN_TYPE_EXIT)) {
+ if (PREDICT_LIKELY(UINT32_MAX - conn->n_read > n_read))
+ conn->n_read += (int)n_read;
+ else
+ conn->n_read = UINT32_MAX;
+ }
}
connection_buckets_decrement(conn, approx_time(), n_read, n_written);
@@ -3594,6 +3606,18 @@ connection_handle_write_impl(connection_t *conn, int force)
edge_conn->n_written = UINT32_MAX;
}
+ /* In TestingTorNetwork mode, update conn->n_written for OR/DIR/EXIT
+ * connections, checking for overflow. */
+ if (n_written && get_options()->TestingTorNetwork &&
+ (conn->type == CONN_TYPE_OR ||
+ conn->type == CONN_TYPE_DIR ||
+ conn->type == CONN_TYPE_EXIT)) {
+ if (PREDICT_LIKELY(UINT32_MAX - conn->n_written > n_written))
+ conn->n_written += (int)n_written;
+ else
+ conn->n_written = UINT32_MAX;
+ }
+
connection_buckets_decrement(conn, approx_time(), n_read, n_written);
if (result > 0) {