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

[or-cvs] r9972: Fix some proposal-104 bugs. (tor/trunk/src/or)



Author: nickm
Date: 2007-04-16 14:54:56 -0400 (Mon, 16 Apr 2007)
New Revision: 9972

Modified:
   tor/trunk/src/or/or.h
   tor/trunk/src/or/rephist.c
   tor/trunk/src/or/router.c
   tor/trunk/src/or/routerlist.c
   tor/trunk/src/or/test.c
Log:
Fix some proposal-104 bugs.

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-04-16 18:39:39 UTC (rev 9971)
+++ tor/trunk/src/or/or.h	2007-04-16 18:54:56 UTC (rev 9972)
@@ -2722,7 +2722,7 @@
 void rep_hist_note_bytes_read(int num_bytes, time_t when);
 void rep_hist_note_bytes_written(int num_bytes, time_t when);
 int rep_hist_bandwidth_assess(void);
-char *rep_hist_get_bandwidth_lines(void);
+char *rep_hist_get_bandwidth_lines(int for_extrainfo);
 void rep_hist_update_state(or_state_t *state);
 int rep_hist_load_state(or_state_t *state, char **err);
 void rep_history_clean(time_t before);

Modified: tor/trunk/src/or/rephist.c
===================================================================
--- tor/trunk/src/or/rephist.c	2007-04-16 18:39:39 UTC (rev 9971)
+++ tor/trunk/src/or/rephist.c	2007-04-16 18:54:56 UTC (rev 9972)
@@ -613,7 +613,7 @@
  * history in its descriptor.
  */
 char *
-rep_hist_get_bandwidth_lines(void)
+rep_hist_get_bandwidth_lines(int for_extrainfo)
 {
   char *buf, *cp;
   char t[ISO_TIME_LEN+1];
@@ -629,7 +629,8 @@
     b = r?read_array:write_array;
     tor_assert(b);
     format_iso_time(t, b->next_period-NUM_SECS_BW_SUM_INTERVAL);
-    tor_snprintf(cp, len-(cp-buf), "opt %s %s (%d s) ",
+    tor_snprintf(cp, len-(cp-buf), "%s%s %s (%d s) ",
+                 for_extrainfo ? "" : "opt ", 
                  r ? "read-history" : "write-history", t,
                  NUM_SECS_BW_SUM_INTERVAL);
     cp += strlen(cp);

Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c	2007-04-16 18:39:39 UTC (rev 9971)
+++ tor/trunk/src/or/router.c	2007-04-16 18:54:56 UTC (rev 9972)
@@ -1244,7 +1244,7 @@
   format_iso_time(published, router->cache_info.published_on);
 
   /* How busy have we been? */
-  bandwidth_usage = rep_hist_get_bandwidth_lines();
+  bandwidth_usage = rep_hist_get_bandwidth_lines(0);
 
   if (router->declared_family && smartlist_len(router->declared_family)) {
     size_t n;
@@ -1397,7 +1397,7 @@
   base16_encode(identity, sizeof(identity),
                 extrainfo->cache_info.identity_digest, DIGEST_LEN);
   format_iso_time(published, extrainfo->cache_info.published_on);
-  bandwidth_usage = rep_hist_get_bandwidth_lines();
+  bandwidth_usage = rep_hist_get_bandwidth_lines(1);
 
   result = tor_snprintf(s, maxlen,
                         "extra-info %s %s\n"

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2007-04-16 18:39:39 UTC (rev 9971)
+++ tor/trunk/src/or/routerlist.c	2007-04-16 18:54:56 UTC (rev 9972)
@@ -1468,7 +1468,7 @@
     r = desc->signed_descriptor_body;
   }
   tor_assert(r);
-  tor_assert(!memcmp("router ", r, 7));
+  tor_assert(!memcmp("router ", r, 7) || !memcmp("extra-info ", r, 11));
 #if 0
   tor_assert(!memcmp("\n-----END SIGNATURE-----\n",
                      r + len - 25, 25));

Modified: tor/trunk/src/or/test.c
===================================================================
--- tor/trunk/src/or/test.c	2007-04-16 18:39:39 UTC (rev 9971)
+++ tor/trunk/src/or/test.c	2007-04-16 18:54:56 UTC (rev 9972)
@@ -1716,7 +1716,7 @@
   r2.exit_policy = &ex1;
   r2.nickname = tor_strdup("Fred");
 
-  bw_lines = rep_hist_get_bandwidth_lines();
+  bw_lines = rep_hist_get_bandwidth_lines(0);
   test_assert(bw_lines);
   test_assert(!strcmpstart(bw_lines, "opt write-history "));