mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
bwauth: update measured bandwidth file comments
We forgot to update function header comments and code comments when we made changes in 0.3.5.1-alpha and later. Closes 30112.
This commit is contained in:
parent
c28cdcc9bf
commit
ce9b101574
@ -199,9 +199,32 @@ dirserv_get_credible_bandwidth_kb(const routerinfo_t *ri)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the measured bandwidth list file, apply it to the list of
|
* Read the measured bandwidth list <b>from_file</b>:
|
||||||
* vote_routerstatus_t and store all the headers in <b>bw_file_headers</b>.
|
* - store all the headers in <b>bw_file_headers</b>,
|
||||||
|
* - apply bandwidth lines to the list of vote_routerstatus_t in
|
||||||
|
* <b>routerstatuses</b>,
|
||||||
|
* - cache bandwidth lines for dirserv_get_bandwidth_for_router(),
|
||||||
|
* - expire old entries in the measured bandwidth cache, and
|
||||||
|
* - store the DIGEST_SHA256 of the contents of the file in <b>digest_out</b>.
|
||||||
|
*
|
||||||
* Returns -1 on error, 0 otherwise.
|
* Returns -1 on error, 0 otherwise.
|
||||||
|
*
|
||||||
|
* If the file can't be read, or is empty:
|
||||||
|
* - <b>bw_file_headers</b> is empty,
|
||||||
|
* - <b>routerstatuses</b> is not modified,
|
||||||
|
* - the measured bandwidth cache is not modified, and
|
||||||
|
* - <b>digest_out</b> is the zero-byte digest.
|
||||||
|
*
|
||||||
|
* Otherwise, if there is an error later in the file:
|
||||||
|
* - <b>bw_file_headers</b> contains all the headers up to the error,
|
||||||
|
* - <b>routerstatuses</b> is updated with all the relay lines up to the error,
|
||||||
|
* - the measured bandwidth cache is updated with all the relay lines up to
|
||||||
|
* the error,
|
||||||
|
* - if the timestamp is valid and recent, old entries in the measured
|
||||||
|
* bandwidth cache are expired, and
|
||||||
|
* - <b>digest_out</b> is the digest up to the first read error (if any).
|
||||||
|
* The digest is taken over all the readable file contents, even if the
|
||||||
|
* file is outdated or unparseable.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
dirserv_read_measured_bandwidths(const char *from_file,
|
dirserv_read_measured_bandwidths(const char *from_file,
|
||||||
@ -223,15 +246,12 @@ dirserv_read_measured_bandwidths(const char *from_file,
|
|||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
crypto_digest_t *digest = crypto_digest256_new(DIGEST_SHA256);
|
crypto_digest_t *digest = crypto_digest256_new(DIGEST_SHA256);
|
||||||
|
|
||||||
/* Initialise line, so that we can't possibly run off the end. */
|
|
||||||
|
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
log_warn(LD_CONFIG, "Can't open bandwidth file at configured location: %s",
|
log_warn(LD_CONFIG, "Can't open bandwidth file at configured location: %s",
|
||||||
from_file);
|
from_file);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If fgets fails, line is either unmodified, or indeterminate. */
|
|
||||||
if (tor_getline(&line,&n,fp) <= 0) {
|
if (tor_getline(&line,&n,fp) <= 0) {
|
||||||
log_warn(LD_DIRSERV, "Empty bandwidth file");
|
log_warn(LD_DIRSERV, "Empty bandwidth file");
|
||||||
goto err;
|
goto err;
|
||||||
@ -345,6 +365,9 @@ dirserv_read_measured_bandwidths(const char *from_file,
|
|||||||
* the header block yet. If we encounter an incomplete bw line, return -1 but
|
* the header block yet. If we encounter an incomplete bw line, return -1 but
|
||||||
* don't warn since there could be additional header lines coming. If we
|
* don't warn since there could be additional header lines coming. If we
|
||||||
* encounter a proper bw line, return 0 (and we got past the headers).
|
* encounter a proper bw line, return 0 (and we got past the headers).
|
||||||
|
*
|
||||||
|
* If the line contains "vote=0", stop parsing it, and return -1, so that the
|
||||||
|
* line is ignored during voting.
|
||||||
*/
|
*/
|
||||||
STATIC int
|
STATIC int
|
||||||
measured_bw_line_parse(measured_bw_line_t *out, const char *orig_line,
|
measured_bw_line_parse(measured_bw_line_t *out, const char *orig_line,
|
||||||
|
Loading…
Reference in New Issue
Block a user