aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-04-16 18:54:56 +0000
committerNick Mathewson <nickm@torproject.org>2007-04-16 18:54:56 +0000
commit17e83a408f06fc1fb5fb9f3b87d37aa28732e2cc (patch)
treedaba5586891fb30c56d8d298a8fc965d34df0b58 /src
parent6d32d9cb2d65c7851d87010e8971ddc271aa031b (diff)
downloadtor-17e83a408f06fc1fb5fb9f3b87d37aa28732e2cc.tar
tor-17e83a408f06fc1fb5fb9f3b87d37aa28732e2cc.tar.gz
Fix some proposal-104 bugs.
svn:r9972
Diffstat (limited to 'src')
-rw-r--r--src/or/or.h2
-rw-r--r--src/or/rephist.c5
-rw-r--r--src/or/router.c4
-rw-r--r--src/or/routerlist.c2
-rw-r--r--src/or/test.c2
5 files changed, 8 insertions, 7 deletions
diff --git a/src/or/or.h b/src/or/or.h
index ff9dfe397..f7ee77e50 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -2722,7 +2722,7 @@ void rep_hist_dump_stats(time_t now, int severity);
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);
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 4f18a093e..c41a33468 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -613,7 +613,7 @@ rep_hist_fill_bandwidth_history(char *buf, size_t len, bw_array_t *b)
* 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 @@ rep_hist_get_bandwidth_lines(void)
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);
diff --git a/src/or/router.c b/src/or/router.c
index c93f40bca..27c803159 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -1244,7 +1244,7 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
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 @@ extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo,
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"
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 9b77e3801..63f3eec29 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -1468,7 +1468,7 @@ signed_descriptor_get_body(signed_descriptor_t *desc)
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));
diff --git a/src/or/test.c b/src/or/test.c
index 6d2736555..73de80fe5 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -1716,7 +1716,7 @@ test_dir_format(void)
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 "));