diff options
author | juga0 <juga@riseup.net> | 2018-05-28 14:41:55 +0000 |
---|---|---|
committer | juga0 <juga@riseup.net> | 2018-07-16 14:43:48 +0000 |
commit | e5dd46beabb7f456fcf4456271676bc507886fe5 (patch) | |
tree | 7344784e22c181373caf368b588b6ac10f88db31 /src/feature/dircache/dirserv.c | |
parent | 8505522e508c8d2379afbd86154a910948cf8c70 (diff) | |
download | tor-e5dd46beabb7f456fcf4456271676bc507886fe5.tar.gz tor-e5dd46beabb7f456fcf4456271676bc507886fe5.zip |
Add the Bandwidth List file headers to votes
* add bwlist_headers argument to dirserv_read_measured_bandwidth
in order to store all the headers found when parsing the file
* add bwlist_headers to networkstatus_t in order to store the
the headers found by the previous function
* include the bandwidth headers as string in vote documents
* add test to check that dirserv_read_measured_bandwidth generates
the bwlist_headers
Diffstat (limited to 'src/feature/dircache/dirserv.c')
-rw-r--r-- | src/feature/dircache/dirserv.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/feature/dircache/dirserv.c b/src/feature/dircache/dirserv.c index 1500467ec0..ea7b29c464 100644 --- a/src/feature/dircache/dirserv.c +++ b/src/feature/dircache/dirserv.c @@ -2599,12 +2599,14 @@ measured_bw_line_apply(measured_bw_line_t *parsed_line, } /** - * Read the measured bandwidth file and apply it to the list of - * vote_routerstatus_t. Returns -1 on error, 0 otherwise. + * Read the measured bandwidth list file, apply it to the list of + * vote_routerstatus_t and store all the headers in <b>bwlist_headers</b>. + * Returns -1 on error, 0 otherwise. */ int dirserv_read_measured_bandwidths(const char *from_file, - smartlist_t *routerstatuses) + smartlist_t *routerstatuses, + smartlist_t *bwlist_headers) { FILE *fp = tor_fopen_cloexec(from_file, "r"); int applied_lines = 0; @@ -2654,6 +2656,8 @@ dirserv_read_measured_bandwidths(const char *from_file, goto err; } + smartlist_add_asprintf(bwlist_headers, "timestamp=%ld", file_time); + if (routerstatuses) smartlist_sort(routerstatuses, compare_vote_routerstatus_entries); @@ -2669,6 +2673,11 @@ dirserv_read_measured_bandwidths(const char *from_file, dirserv_cache_measured_bw(&parsed_line, file_time); if (measured_bw_line_apply(&parsed_line, routerstatuses) > 0) applied_lines++; + } else { + if (strcmp(line, "====\n") != 0) { + line[strlen(line)-1] = '\0'; + smartlist_add_strdup(bwlist_headers, line); + }; } } } |