diff options
author | Roger Dingledine <arma@torproject.org> | 2016-05-11 17:34:38 -0400 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2016-05-11 17:34:38 -0400 |
commit | 694f1fe80874b2280717908d10d40b45e9e2cc82 (patch) | |
tree | f642d8862242c430869539492659180b510b79a4 /src/or/dirvote.c | |
parent | 9e44273a4a22803eff900f6df10f13c7548bdb0d (diff) | |
download | tor-694f1fe80874b2280717908d10d40b45e9e2cc82.tar.gz tor-694f1fe80874b2280717908d10d40b45e9e2cc82.zip |
write v3-status-votes file earlier in consensus voting
Make directory authorities write the v3-status-votes file out
to disk earlier in the consensus process, so we have the votes
even if we abort the consensus process later on.
Resolves ticket 19036.
Diffstat (limited to 'src/or/dirvote.c')
-rw-r--r-- | src/or/dirvote.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/or/dirvote.c b/src/or/dirvote.c index 9854af7d7f..11b4fd1583 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -3040,6 +3040,26 @@ dirvote_compute_consensuses(void) if (!pending_vote_list) pending_vote_list = smartlist_new(); + /* write the votes out to disk early, so we have them even if we abort + * the consensus process below. */ + votes = smartlist_new(); + votestrings = smartlist_new(); + SMARTLIST_FOREACH(pending_vote_list, pending_vote_t *, v, + { + sized_chunk_t *c = tor_malloc(sizeof(sized_chunk_t)); + c->bytes = v->vote_body->dir; + c->len = v->vote_body->dir_len; + smartlist_add(votestrings, c); /* collect strings to write to disk */ + + smartlist_add(votes, v->vote); /* collect votes to compute consensus */ + }); + + votefile = get_datadir_fname("v3-status-votes"); + write_chunks_to_file(votefile, votestrings, 0, 0); + tor_free(votefile); + SMARTLIST_FOREACH(votestrings, sized_chunk_t *, c, tor_free(c)); + smartlist_free(votestrings); + n_voters = get_n_authorities(V3_DIRINFO); n_votes = smartlist_len(pending_vote_list); if (n_votes <= n_voters/2) { @@ -3066,24 +3086,6 @@ dirvote_compute_consensuses(void) goto err; } - votes = smartlist_new(); - votestrings = smartlist_new(); - SMARTLIST_FOREACH(pending_vote_list, pending_vote_t *, v, - { - sized_chunk_t *c = tor_malloc(sizeof(sized_chunk_t)); - c->bytes = v->vote_body->dir; - c->len = v->vote_body->dir_len; - smartlist_add(votestrings, c); /* collect strings to write to disk */ - - smartlist_add(votes, v->vote); /* collect votes to compute consensus */ - }); - - votefile = get_datadir_fname("v3-status-votes"); - write_chunks_to_file(votefile, votestrings, 0, 0); - tor_free(votefile); - SMARTLIST_FOREACH(votestrings, sized_chunk_t *, c, tor_free(c)); - smartlist_free(votestrings); - { char legacy_dbuf[DIGEST_LEN]; crypto_pk_t *legacy_sign=NULL; |