diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-07-27 18:33:30 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-07-27 18:33:30 +0000 |
commit | 10f166045befc11c3e98189dda7f607ab9e098dd (patch) | |
tree | 9cf93c3ceb6e8933c3994461f91ea7bb197997c1 /src | |
parent | a65cea38d2ff3b306b9b1477309c9bf60392228a (diff) | |
download | tor-10f166045befc11c3e98189dda7f607ab9e098dd.tar tor-10f166045befc11c3e98189dda7f607ab9e098dd.tar.gz |
r13937@catbus: nickm | 2007-07-27 12:43:36 -0400
Maintain a detached-signatures document along with pending consensus document. Add a dirvote_free_all() to clean up static vars in dirvote.c
svn:r10945
Diffstat (limited to 'src')
-rw-r--r-- | src/or/dirvote.c | 28 | ||||
-rw-r--r-- | src/or/main.c | 1 | ||||
-rw-r--r-- | src/or/or.h | 2 |
3 files changed, 30 insertions, 1 deletions
diff --git a/src/or/dirvote.c b/src/or/dirvote.c index 5d89b473d..8be8a5775 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -1065,6 +1065,8 @@ static smartlist_t *pending_vote_list = NULL; /** DOCDOC */ static char *pending_consensus_body = NULL; /** DOCDOC */ +static char *pending_consensus_signatures = NULL; +/** DOCDOC */ static networkstatus_vote_t *pending_consensus = NULL; /** DOCDOC */ @@ -1177,7 +1179,7 @@ dirvote_compute_consensus(void) /* Have we got enough votes to try? */ int n_votes, n_voters; smartlist_t *votes = NULL; - char *consensus_body = NULL; + char *consensus_body = NULL, *signatures = NULL; networkstatus_vote_t *consensus = NULL; authority_cert_t *my_cert; @@ -1207,9 +1209,16 @@ dirvote_compute_consensus(void) log_warn(LD_DIR, "Couldn't parse consensus we generated!"); goto err; } + signatures = networkstatus_get_detached_signatures(consensus); + if (!signatures) { + log_warn(LD_DIR, "Couldn't extract signatures."); + goto err; + } tor_free(pending_consensus_body); pending_consensus_body = consensus_body; + tor_free(pending_consensus_signatures); + pending_consensus_signatures = signatures; if (pending_consensus) networkstatus_vote_free(pending_consensus); @@ -1220,8 +1229,25 @@ dirvote_compute_consensus(void) if (votes) smartlist_free(votes); tor_free(consensus_body); + tor_free(signatures); networkstatus_vote_free(consensus); return -1; } +/** Release all static storage held in dirvote.c */ +void +dirvote_free_all(void) +{ + dirvote_clear_pending_votes(); + if (pending_vote_list) { + smartlist_free(pending_vote_list); + pending_vote_list = NULL; + } + tor_free(pending_consensus_body); + tor_free(pending_consensus_signatures); + if (pending_consensus) { + networkstatus_vote_free(pending_consensus); + pending_consensus = NULL; + } +} diff --git a/src/or/main.c b/src/or/main.c index 6e449e0ef..e25238307 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -1764,6 +1764,7 @@ tor_free_all(int postfork) if (!postfork) { evdns_shutdown(1); } + dirvote_free_all(); routerlist_free_all(); addressmap_free_all(); set_exit_redirects(NULL); /* free the registered exit redirects */ diff --git a/src/or/or.h b/src/or/or.h index e54b39b96..8b46391e7 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -2793,6 +2793,8 @@ format_networkstatus_vote(crypto_pk_env_t *private_key, /********************************* dirvote.c ************************/ +void dirvote_free_all(void); + /* vote manipulation */ void networkstatus_vote_free(networkstatus_vote_t *ns); char *networkstatus_compute_consensus(smartlist_t *votes, |