mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Fix a bug weasel found: when we are an authority and somebody requests "all" statuses, cconsider regenerating our own.
svn:r5466
This commit is contained in:
+13
-5
@@ -1139,6 +1139,14 @@ router_is_general_exit(routerinfo_t *ri)
|
||||
/** For authoritative directories: the current (v2) network status */
|
||||
static cached_dir_t the_v2_networkstatus = { NULL, NULL, 0, 0, 0 };
|
||||
|
||||
static int
|
||||
should_generate_v2_networkstatus(void)
|
||||
{
|
||||
return get_options()->AuthoritativeDir &&
|
||||
the_v2_networkstatus_is_dirty &&
|
||||
the_v2_networkstatus_is_dirty + DIR_REGEN_SLACK_TIME < time(NULL);
|
||||
}
|
||||
|
||||
/** For authoritative directories only: replace the contents of
|
||||
* <b>the_v2_networkstatus</b> with a newly generated network status
|
||||
* object. */
|
||||
@@ -1336,7 +1344,10 @@ dirserv_get_networkstatus_v2(smartlist_t *result,
|
||||
warn(LD_BUG,"Unable to generate an authoritative network status.");
|
||||
}
|
||||
} else if (!strcmp(key, "all")) {
|
||||
digestmap_iter_t *iter = digestmap_iter_init(cached_v2_networkstatus);
|
||||
digestmap_iter_t *iter;
|
||||
if (should_generate_v2_networkstatus(void))
|
||||
generate_v2_networkstatus();
|
||||
iter = digestmap_iter_init(cached_v2_networkstatus);
|
||||
while (!digestmap_iter_done(iter)) {
|
||||
const char *ident;
|
||||
void *val;
|
||||
@@ -1353,10 +1364,7 @@ dirserv_get_networkstatus_v2(smartlist_t *result,
|
||||
SMARTLIST_FOREACH(digests, char *, cp,
|
||||
{
|
||||
cached_dir_t *cached;
|
||||
if (router_digest_is_me(cp) &&
|
||||
get_options()->AuthoritativeDir &&
|
||||
the_v2_networkstatus_is_dirty &&
|
||||
the_v2_networkstatus_is_dirty + DIR_REGEN_SLACK_TIME < time(NULL))
|
||||
if (router_digest_is_me(cp) && should_generate_v2_networkstatus(void))
|
||||
generate_v2_networkstatus();
|
||||
cached = digestmap_get(cached_v2_networkstatus, cp);
|
||||
if (cached) {
|
||||
|
||||
Reference in New Issue
Block a user