[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] only count bytes transmitted to/from non-local IPs



Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	connection.c main.c rephist.c 
Log Message:
only count bytes transmitted to/from non-local IPs


Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.238
retrieving revision 1.239
diff -u -d -r1.238 -r1.239
--- connection.c	13 Jul 2004 07:42:20 -0000	1.238
+++ connection.c	13 Jul 2004 16:58:01 -0000	1.239
@@ -711,7 +711,7 @@
   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 @@
       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 @@
     }
   }
 
-  if(result > 0) { /* remember it */
+  if(result > 0 && !is_local_IP(conn->addr)) { /* remember it */
     rep_hist_note_bytes_written(result, now);
   }
 

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.290
retrieving revision 1.291
diff -u -d -r1.290 -r1.291
--- main.c	13 Jul 2004 07:42:20 -0000	1.290
+++ main.c	13 Jul 2004 16:58:01 -0000	1.291
@@ -390,7 +390,7 @@
   }
 }
 
-#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 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 @@
 
   /* 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. */

Index: rephist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rephist.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- rephist.c	13 Jul 2004 07:42:20 -0000	1.11
+++ rephist.c	13 Jul 2004 16:58:01 -0000	1.12
@@ -295,7 +295,7 @@
  * 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 @@
 /* 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.
  */