aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-07-13 16:58:01 +0000
committerRoger Dingledine <arma@torproject.org>2004-07-13 16:58:01 +0000
commitd37850bb98abe0ae35a35c648392f91fdfe019a4 (patch)
tree279499b6239e2f29f654be7ecd0fa62f3dc721ae
parent7e344f191aeb2de6ffb9509e0508ce8647764159 (diff)
downloadtor-d37850bb98abe0ae35a35c648392f91fdfe019a4.tar
tor-d37850bb98abe0ae35a35c648392f91fdfe019a4.tar.gz
only count bytes transmitted to/from non-local IPs
svn:r2041
-rw-r--r--src/or/connection.c8
-rw-r--r--src/or/main.c9
-rw-r--r--src/or/rephist.c4
3 files changed, 10 insertions, 11 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 7bfd20f31..fb7357662 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -711,7 +711,7 @@ int connection_handle_read(connection_t *conn) {
if(connection_read_to_buf(conn) < 0) {
/* There's a read error; kill the connection.*/
connection_close_immediate(conn); /* Don't flush; connection is dead. */
- conn->has_sent_end = 1;
+ conn->has_sent_end = 1; /* XXX have we already sent the end? really? */
connection_mark_for_close(conn);
if(conn->type == CONN_TYPE_DIR &&
conn->state == DIR_CONN_STATE_CONNECTING) {
@@ -781,6 +781,10 @@ static int connection_read_to_buf(connection_t *conn) {
return -1;
}
+ if(result > 0 && !is_local_IP(conn->addr)) { /* remember it */
+ rep_hist_note_bytes_read(result, time(NULL));
+ }
+
connection_bucket_decrement(conn, result);
return 0;
}
@@ -900,7 +904,7 @@ int connection_handle_write(connection_t *conn) {
}
}
- if(result > 0) { /* remember it */
+ if(result > 0 && !is_local_IP(conn->addr)) { /* remember it */
rep_hist_note_bytes_written(result, now);
}
diff --git a/src/or/main.c b/src/or/main.c
index 87f4e39b0..24fd1d31c 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -390,7 +390,7 @@ static void run_connection_housekeeping(int i, time_t now) {
}
}
-#define MIN_BW_TO_PUBLISH_DESC 5000 /* 5000 bytes sustained */
+#define MIN_BW_TO_PUBLISH_DESC 5000 /* 5000 bytes/s sustained */
#define MIN_UPTIME_TO_PUBLISH_DESC (30*60) /* half an hour */
/** Decide if we're a server or just a client. We are a server if:
@@ -542,7 +542,6 @@ static void run_scheduled_events(time_t now) {
static int prepare_for_poll(void) {
static long current_second = 0; /* from previous calls to gettimeofday */
connection_t *conn;
- int bytes_read;
struct timeval now;
int i;
@@ -550,12 +549,8 @@ static int prepare_for_poll(void) {
/* Check how much bandwidth we've consumed, and increment the token
* buckets. */
- bytes_read = stats_prev_global_read_bucket - global_read_bucket;
- stats_n_bytes_read += bytes_read;
+ stats_n_bytes_read += stats_prev_global_read_bucket - global_read_bucket;
connection_bucket_refill(&now);
- if (bytes_read > 0) {
- rep_hist_note_bytes_read(bytes_read, now.tv_sec);
- }
stats_prev_global_read_bucket = global_read_bucket;
if(now.tv_sec > current_second) { /* the second has rolled over. check more stuff. */
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 0e1471421..fb282f469 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -295,7 +295,7 @@ void write_rep_history(const char *filename)
* Add num_bytes to the current running total for <b>when</b>.
*
* <b>when</b> can go back to time, but it's safe to ignore calls
- * earlier that the latest <b>when</b> you've heard of.
+ * earlier than the latest <b>when</b> you've heard of.
*/
void rep_hist_note_bytes_written(int num_bytes, time_t when) {
/* Maybe a circular array for recent seconds, and step to a new point
@@ -327,7 +327,7 @@ int rep_hist_bandwidth_assess(time_t when) {
/* To get a handle on space complexity, I promise I will call this
* function at most every options.DirFetchPostPeriod seconds. So in
* rep_hist_note_bytes_foo() above, you could keep a running max sum
- * for the current period, and when the period ends you can tuck it away
+ * for the current period, and when the period ends you can tuck its max away
* in a circular array of more managable size. We lose a bit of precision,
* but this is all guesswork anyway.
*/