]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
dirvote: Free vote commits in the dirauth module
authorDavid Goulet <dgoulet@torproject.org>
Wed, 25 Apr 2018 14:49:32 +0000 (10:49 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Tue, 1 May 2018 14:06:13 +0000 (10:06 -0400)
In order to make sr_commit_free() only used by the dirauth module, this
commits moves the commits free from a vote object into the dirvote.c file
which is now only for the module.

The function does nothing if the module is disabled.

Signed-off-by: David Goulet <dgoulet@torproject.org>
src/or/dirauth/dirvote.c
src/or/dirauth/dirvote.h
src/or/networkstatus.c

index 3ec4d67416b998ca237758908ab55e315eff72d0..53a896eb4db78605a274317222a7fbf134319328 100644 (file)
@@ -3899,3 +3899,16 @@ dirvote_parse_sr_commits(networkstatus_t *ns, smartlist_t *tokens)
   }
 }
 
+/* For the given vote, free the shared random commits if any. */
+void
+dirvote_clear_commits(networkstatus_t *ns)
+{
+  tor_assert(ns->type == NS_TYPE_VOTE);
+
+  if (ns->sr_info.commits) {
+    SMARTLIST_FOREACH(ns->sr_info.commits, sr_commit_t *, c,
+                      sr_commit_free(c));
+    smartlist_free(ns->sr_info.commits);
+  }
+}
+
index 4514c6daf01143eb637e23fdec256db833ad4d2d..9682c60364872667f35cda10c059565aa001fc1e 100644 (file)
@@ -100,6 +100,7 @@ void dirvote_act(const or_options_t *options, time_t now);
 void dirvote_free_all(void);
 
 void dirvote_parse_sr_commits(networkstatus_t *ns, smartlist_t *tokens);
+void dirvote_clear_commits(networkstatus_t *ns);
 
 #else /* HAVE_MODULE_DIRAUTH */
 
@@ -122,6 +123,12 @@ dirvote_parse_sr_commits(networkstatus_t *ns, smartlist_t *tokens)
   (void) tokens;
 }
 
+static inline void
+dirvote_clear_commits(networkstatus_t *ns)
+{
+  (void) ns;
+}
+
 #endif /* HAVE_MODULE_DIRAUTH */
 
 void dirvote_recalculate_timing(const or_options_t *options, time_t now);
index fa8d0bcf13072f25ae255e7bd3dfe806c39992a3..5ca320d284060ca281f1369011facb18cad61d8a 100644 (file)
@@ -366,9 +366,7 @@ networkstatus_vote_free_(networkstatus_t *ns)
   digestmap_free(ns->desc_digest_map, NULL);
 
   if (ns->sr_info.commits) {
-    SMARTLIST_FOREACH(ns->sr_info.commits, sr_commit_t *, c,
-                      sr_commit_free(c));
-    smartlist_free(ns->sr_info.commits);
+    dirvote_clear_commits(ns);
   }
   tor_free(ns->sr_info.previous_srv);
   tor_free(ns->sr_info.current_srv);