[or-cvs] r10945: Maintain a detached-signatures document along with pending c (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Fri Jul 27 18:33:33 UTC 2007


Author: nickm
Date: 2007-07-27 14:33:30 -0400 (Fri, 27 Jul 2007)
New Revision: 10945

Modified:
   tor/trunk/
   tor/trunk/src/or/dirvote.c
   tor/trunk/src/or/main.c
   tor/trunk/src/or/or.h
Log:
 r13937 at 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



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r13937] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/or/dirvote.c
===================================================================
--- tor/trunk/src/or/dirvote.c	2007-07-27 18:33:28 UTC (rev 10944)
+++ tor/trunk/src/or/dirvote.c	2007-07-27 18:33:30 UTC (rev 10945)
@@ -1065,6 +1065,8 @@
 /** 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 @@
   /* 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 @@
     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 @@
   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;
+  }
+}

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2007-07-27 18:33:28 UTC (rev 10944)
+++ tor/trunk/src/or/main.c	2007-07-27 18:33:30 UTC (rev 10945)
@@ -1764,6 +1764,7 @@
   if (!postfork) {
     evdns_shutdown(1);
   }
+  dirvote_free_all();
   routerlist_free_all();
   addressmap_free_all();
   set_exit_redirects(NULL); /* free the registered exit redirects */

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-07-27 18:33:28 UTC (rev 10944)
+++ tor/trunk/src/or/or.h	2007-07-27 18:33:30 UTC (rev 10945)
@@ -2793,6 +2793,8 @@
 
 /********************************* dirvote.c ************************/
 
+void dirvote_free_all(void);
+
 /* vote manipulation */
 void networkstatus_vote_free(networkstatus_vote_t *ns);
 char *networkstatus_compute_consensus(smartlist_t *votes,



More information about the tor-commits mailing list