summaryrefslogtreecommitdiff
path: root/src/or/connection.c
diff options
context:
space:
mode:
authorKarsten Loesing <karsten.loesing@gmx.net>2010-07-07 14:55:42 +0200
committerKarsten Loesing <karsten.loesing@gmx.net>2010-08-18 13:54:41 +0200
commitdb94b7f46ef02d5a1de132a5b746b350f3d066b7 (patch)
tree8b5dd5963a87c29403b1c28e1a55b23cb13ad247 /src/or/connection.c
parent863b6c439e6bfc64f602ecb9526940fa966ca9fe (diff)
downloadtor-db94b7f46ef02d5a1de132a5b746b350f3d066b7.tar.gz
tor-db94b7f46ef02d5a1de132a5b746b350f3d066b7.zip
Count bytes we spend on answering directory requests.
Diffstat (limited to 'src/or/connection.c')
-rw-r--r--src/or/connection.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 55d2fa8146..5438cf7d0d 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -2082,8 +2082,6 @@ static void
connection_buckets_decrement(connection_t *conn, time_t now,
size_t num_read, size_t num_written)
{
- if (!connection_is_rate_limited(conn))
- return; /* local IPs are free */
if (num_written >= INT_MAX || num_read >= INT_MAX) {
log_err(LD_BUG, "Value out of range. num_read=%lu, num_written=%lu, "
"connection type=%s, state=%s",
@@ -2095,6 +2093,16 @@ connection_buckets_decrement(connection_t *conn, time_t now,
tor_fragile_assert();
}
+ /* Count bytes of answering direct and tunneled directory requests */
+ if (conn->type == CONN_TYPE_DIR && conn->purpose == DIR_PURPOSE_SERVER) {
+ if (num_read > 0)
+ rep_hist_note_dir_bytes_read(num_read, now);
+ if (num_written > 0)
+ rep_hist_note_dir_bytes_written(num_written, now);
+ }
+
+ if (!connection_is_rate_limited(conn))
+ return; /* local IPs are free */
if (num_read > 0) {
if (conn->type == CONN_TYPE_EXIT)
rep_hist_note_exit_bytes_read(conn->port, num_read);