diff options
author | David Goulet <dgoulet@torproject.org> | 2021-05-27 10:01:44 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2021-05-27 10:01:44 -0400 |
commit | fd3678fa60b3ba66fa414f86ce962f380ca6462e (patch) | |
tree | a2eaf81a64fcd495e9fb6954ebeb9c28936ef610 /src/feature/control | |
parent | bab2b29f89f21781a87010cf7120615615b90599 (diff) | |
parent | d12b16614d09b303f9ef9624107b589264537341 (diff) | |
download | tor-fd3678fa60b3ba66fa414f86ce962f380ca6462e.tar.gz tor-fd3678fa60b3ba66fa414f86ce962f380ca6462e.zip |
Merge branch 'tor-gitlab/mr/392' into maint-0.4.6
Diffstat (limited to 'src/feature/control')
-rw-r--r-- | src/feature/control/control_getinfo.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/feature/control/control_getinfo.c b/src/feature/control/control_getinfo.c index 48756b4989..e6874b0cf5 100644 --- a/src/feature/control/control_getinfo.c +++ b/src/feature/control/control_getinfo.c @@ -352,26 +352,24 @@ getinfo_helper_current_consensus(consensus_flavor_t flavor, *errmsg = "Internal error: unrecognized flavor name."; return -1; } - if (we_want_to_fetch_flavor(get_options(), flavor)) { - /** Check from the cache */ - const cached_dir_t *consensus = dirserv_get_consensus(flavor_name); - if (consensus) { - *answer = tor_strdup(consensus->dir); - } + tor_mmap_t *mapped = networkstatus_map_cached_consensus(flavor_name); + if (mapped) { + *answer = tor_memdup_nulterm(mapped->data, mapped->size); + tor_munmap_file(mapped); } - if (!*answer) { /* try loading it from disk */ - - tor_mmap_t *mapped = networkstatus_map_cached_consensus(flavor_name); - if (mapped) { - *answer = tor_memdup_nulterm(mapped->data, mapped->size); - tor_munmap_file(mapped); - } - if (!*answer) { /* generate an error */ - *errmsg = "Could not open cached consensus. " - "Make sure FetchUselessDescriptors is set to 1."; - return -1; + if (!*answer) { /* Maybe it's in the cache? */ + if (we_want_to_fetch_flavor(get_options(), flavor)) { + const cached_dir_t *consensus = dirserv_get_consensus(flavor_name); + if (consensus) { + *answer = tor_strdup(consensus->dir); + } } } + if (!*answer) { /* generate an error */ + *errmsg = "Could not open cached consensus. " + "Make sure FetchUselessDescriptors is set to 1."; + return -1; + } return 0; } |