|
@@ -1739,6 +1739,10 @@ networkstatus_set_current_consensus(const char *consensus,
|
|
|
if (current_ns_consensus) {
|
|
|
networkstatus_copy_old_consensus_info(c, current_ns_consensus);
|
|
|
networkstatus_vote_free(current_ns_consensus);
|
|
|
+ /* Defensive programming : we should set current_consensus very soon,
|
|
|
+ * but we're about to call some stuff in the meantime, and leaving this
|
|
|
+ * dangling pointer around has proven to be trouble. */
|
|
|
+ current_ns_consensus = NULL;
|
|
|
}
|
|
|
current_ns_consensus = c;
|
|
|
free_consensus = 0; /* avoid free */
|
|
@@ -1746,6 +1750,8 @@ networkstatus_set_current_consensus(const char *consensus,
|
|
|
if (current_md_consensus) {
|
|
|
networkstatus_copy_old_consensus_info(c, current_md_consensus);
|
|
|
networkstatus_vote_free(current_md_consensus);
|
|
|
+ /* more defensive programming */
|
|
|
+ current_md_consensus = NULL;
|
|
|
}
|
|
|
current_md_consensus = c;
|
|
|
free_consensus = 0; /* avoid free */
|
|
@@ -1773,13 +1779,6 @@ networkstatus_set_current_consensus(const char *consensus,
|
|
|
download_status_failed(&consensus_dl_status[flav], 0);
|
|
|
}
|
|
|
|
|
|
- if (directory_caches_dir_info(options)) {
|
|
|
- dirserv_set_cached_consensus_networkstatus(consensus,
|
|
|
- flavor,
|
|
|
- &c->digests,
|
|
|
- c->valid_after);
|
|
|
- }
|
|
|
-
|
|
|
if (flav == USABLE_CONSENSUS_FLAVOR) {
|
|
|
/* XXXXNM Microdescs: needs a non-ns variant. */
|
|
|
update_consensus_networkstatus_fetch_time(now);
|
|
@@ -1796,6 +1795,13 @@ networkstatus_set_current_consensus(const char *consensus,
|
|
|
circuit_build_times_new_consensus_params(&circ_times, current_consensus);
|
|
|
}
|
|
|
|
|
|
+ if (directory_caches_dir_info(options)) {
|
|
|
+ dirserv_set_cached_consensus_networkstatus(consensus,
|
|
|
+ flavor,
|
|
|
+ &c->digests,
|
|
|
+ c->valid_after);
|
|
|
+ }
|
|
|
+
|
|
|
if (!from_cache) {
|
|
|
write_str_to_file(consensus_fname, consensus, 0);
|
|
|
}
|