diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-10-20 13:53:11 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-10-20 13:53:11 -0400 |
commit | 444193ff5df901073823e38fc291e913164e61e0 (patch) | |
tree | 54c423d846cbc10bf105527656713f2a7f0e8540 /src/or/networkstatus.c | |
parent | ca7d5dc29920a8ae406e6a79cb3f987871790edf (diff) | |
parent | 2849a95691c002108666eb414ff497bf93349e7d (diff) | |
download | tor-444193ff5df901073823e38fc291e913164e61e0.tar.gz tor-444193ff5df901073823e38fc291e913164e61e0.zip |
Merge remote branch 'origin/maint-0.2.2'
Conflicts:
src/or/networkstatus.c
Diffstat (limited to 'src/or/networkstatus.c')
-rw-r--r-- | src/or/networkstatus.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index a99893f4ee..7ff6a8b631 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -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); } |