summaryrefslogtreecommitdiff
path: root/src/feature/dirclient
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2021-05-27 10:01:49 -0400
committerDavid Goulet <dgoulet@torproject.org>2021-05-27 10:01:49 -0400
commitc29ba98ce861a2185a818415e035a9a0803f2ab6 (patch)
tree0a1eb9bb981a3601b3eeaad9ea0d7832d071cff4 /src/feature/dirclient
parent1665d1194263ac595cf6ad24cb38d80c7ec446a5 (diff)
parentfd3678fa60b3ba66fa414f86ce962f380ca6462e (diff)
downloadtor-c29ba98ce861a2185a818415e035a9a0803f2ab6.tar.gz
tor-c29ba98ce861a2185a818415e035a9a0803f2ab6.zip
Merge branch 'maint-0.4.6'
Diffstat (limited to 'src/feature/dirclient')
-rw-r--r--src/feature/dirclient/dirclient.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/feature/dirclient/dirclient.c b/src/feature/dirclient/dirclient.c
index 24a32ef201..67fe2e7fb2 100644
--- a/src/feature/dirclient/dirclient.c
+++ b/src/feature/dirclient/dirclient.c
@@ -2220,18 +2220,23 @@ handle_response_fetch_consensus(dir_connection_t *conn,
if (looks_like_a_consensus_diff(body, body_len)) {
/* First find our previous consensus. Maybe it's in ram, maybe not. */
- cached_dir_t *cd = dirserv_get_consensus(flavname);
+ cached_dir_t *cd = NULL;
const char *consensus_body = NULL;
size_t consensus_body_len;
tor_mmap_t *mapped_consensus = NULL;
- if (cd) {
- consensus_body = cd->dir;
- consensus_body_len = cd->dir_len;
+
+ /* We prefer the mmap'd version over the cached_dir_t version,
+ * since that matches the logic we used when we picked a consensus
+ * back in dir_consensus_request_set_additional_headers. */
+ mapped_consensus = networkstatus_map_cached_consensus(flavname);
+ if (mapped_consensus) {
+ consensus_body = mapped_consensus->data;
+ consensus_body_len = mapped_consensus->size;
} else {
- mapped_consensus = networkstatus_map_cached_consensus(flavname);
- if (mapped_consensus) {
- consensus_body = mapped_consensus->data;
- consensus_body_len = mapped_consensus->size;
+ cd = dirserv_get_consensus(flavname);
+ if (cd) {
+ consensus_body = cd->dir;
+ consensus_body_len = cd->dir_len;
}
}
if (!consensus_body) {