aboutsummaryrefslogtreecommitdiff
path: root/src/or/dirserv.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-02-19 14:54:05 -0500
committerNick Mathewson <nickm@torproject.org>2013-02-19 14:54:05 -0500
commitb0b0d6af6369f53caed2222837149dc4a90c739c (patch)
tree89dede41d6101c26d17ceb5a52f1421a1e8b3c41 /src/or/dirserv.c
parentf2199763cf7c57744a885c12afcfa7b9df304629 (diff)
parent699c39dada7f76d5b0cc8dd4b56df1fe4bba7763 (diff)
downloadtor-b0b0d6af6369f53caed2222837149dc4a90c739c.tar.gz
tor-b0b0d6af6369f53caed2222837149dc4a90c739c.zip
Merge branch 'bug2286_unit_test_squashed'
Diffstat (limited to 'src/or/dirserv.c')
-rw-r--r--src/or/dirserv.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 0819d4bd24..badacd683d 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -2101,13 +2101,15 @@ version_from_platform(const char *platform)
* NS_V3_CONSENSUS - Output the first portion of a V3 NS consensus entry
* NS_V3_CONSENSUS_MICRODESC - Output the first portion of a V3 microdesc
* consensus entry.
- * NS_V3_VOTE - Output a complete V3 NS vote
+ * NS_V3_VOTE - Output a complete V3 NS vote. If <b>vrs</b> is present,
+ * it contains additional information for the vote.
* NS_CONTROL_PORT - Output a NS document for the control port
*/
int
routerstatus_format_entry(char *buf, size_t buf_len,
const routerstatus_t *rs, const char *version,
- routerstatus_format_type_t format)
+ routerstatus_format_type_t format,
+ const vote_routerstatus_t *vrs)
{
int r;
char *cp;
@@ -2253,10 +2255,10 @@ routerstatus_format_entry(char *buf, size_t buf_len,
return -1;
}
cp += strlen(cp);
- if (format == NS_V3_VOTE && rs->has_measured_bw) {
+ if (format == NS_V3_VOTE && vrs && vrs->has_measured_bw) {
*--cp = '\0'; /* Kill "\n" */
r = tor_snprintf(cp, buf_len - (cp-buf),
- " Measured=%d\n", rs->measured_bw);
+ " Measured=%d\n", vrs->measured_bw);
if (r<0) {
log_warn(LD_BUG, "Not enough space in buffer for weight line.");
return -1;
@@ -2639,12 +2641,12 @@ int
measured_bw_line_apply(measured_bw_line_t *parsed_line,
smartlist_t *routerstatuses)
{
- routerstatus_t *rs = NULL;
+ vote_routerstatus_t *rs = NULL;
if (!routerstatuses)
return 0;
rs = smartlist_bsearch(routerstatuses, parsed_line->node_id,
- compare_digest_to_routerstatus_entry);
+ compare_digest_to_vote_routerstatus_entry);
if (rs) {
rs->has_measured_bw = 1;
@@ -2659,7 +2661,7 @@ measured_bw_line_apply(measured_bw_line_t *parsed_line,
/**
* Read the measured bandwidth file and apply it to the list of
- * routerstatuses. Returns -1 on error, 0 otherwise.
+ * vote_routerstatus_t. Returns -1 on error, 0 otherwise.
*/
int
dirserv_read_measured_bandwidths(const char *from_file,
@@ -2701,7 +2703,7 @@ dirserv_read_measured_bandwidths(const char *from_file,
}
if (routerstatuses)
- smartlist_sort(routerstatuses, compare_routerstatus_entries);
+ smartlist_sort(routerstatuses, compare_vote_routerstatus_entries);
while (!feof(fp)) {
measured_bw_line_t parsed_line;
@@ -3052,7 +3054,8 @@ generate_v2_networkstatus_opinion(void)
if (digestmap_get(omit_as_sybil, ri->cache_info.identity_digest))
clear_status_flags_on_sybil(&rs);
- if (routerstatus_format_entry(outp, endp-outp, &rs, version, NS_V2)) {
+ if (routerstatus_format_entry(outp, endp-outp, &rs, version, NS_V2,
+ NULL)) {
log_warn(LD_BUG, "Unable to print router status.");
tor_free(version);
goto done;