summaryrefslogtreecommitdiff
path: root/src/feature/control
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2021-05-27 10:01:44 -0400
committerDavid Goulet <dgoulet@torproject.org>2021-05-27 10:01:44 -0400
commitfd3678fa60b3ba66fa414f86ce962f380ca6462e (patch)
treea2eaf81a64fcd495e9fb6954ebeb9c28936ef610 /src/feature/control
parentbab2b29f89f21781a87010cf7120615615b90599 (diff)
parentd12b16614d09b303f9ef9624107b589264537341 (diff)
downloadtor-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.c32
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;
}