[tor-commits] [tor/master] Add accessors as needed to repair compilation

nickm at torproject.org nickm at torproject.org
Fri Dec 16 16:26:17 UTC 2016


commit c74542c51a2ce75e602e3e237bd41d1fd08a2fb0
Author: Nick Mathewson <nickm at torproject.org>
Date:   Tue Nov 15 08:15:29 2016 -0500

    Add accessors as needed to repair compilation
    
    The previous commit, in moving a bunch of functions to bridges.c,
    broke compilation because bridges.c required two entry points to
    entrynodes.c it didn't have.
---
 src/or/bridges.c    | 16 +---------------
 src/or/entrynodes.c | 23 +++++++++++++++++++++++
 src/or/entrynodes.h |  5 +++++
 3 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/src/or/bridges.c b/src/or/bridges.c
index 73510cf..508c77f 100644
--- a/src/or/bridges.c
+++ b/src/or/bridges.c
@@ -52,7 +52,6 @@ typedef struct {
 } bridge_info_t;
 
 static void bridge_free(bridge_info_t *bridge);
-static int num_bridges_usable(void);
 
 /** A list of configured bridges. Whenever we actually get a descriptor
  * for one, we add it as an entry guard.  Note that the order of bridges
@@ -719,7 +718,7 @@ learned_bridge_descriptor(routerinfo_t *ri, int from_cache)
                    fmt_and_decorate_addr(&bridge->addr),
                    (int) bridge->port);
       }
-      add_an_entry_guard(get_guard_selection_info(), node, 1, 1, 0, 0);
+      add_bridge_as_entry_guard(get_guard_selection_info(), node);
 
       log_notice(LD_DIR, "new bridge descriptor '%s' (%s): %s", ri->nickname,
                  from_cache ? "cached" : "fresh", router_describe(ri));
@@ -747,19 +746,6 @@ any_bridge_descriptors_known(void)
   return choose_random_entry(NULL) != NULL;
 }
 
-/** Return the number of bridges that have descriptors that are marked with
- * purpose 'bridge' and are running.
- */
-static int
-num_bridges_usable(void)
-{
-  int n_options = 0;
-  tor_assert(get_options()->UseBridges);
-  (void) choose_random_entry_impl(get_guard_selection_info(),
-                                  NULL, 0, 0, &n_options);
-  return n_options;
-}
-
 /** Return a smartlist containing all bridge identity digests */
 MOCK_IMPL(smartlist_t *,
 list_bridge_identities, (void))
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 886e653..95b3c5a 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -893,6 +893,16 @@ add_an_entry_guard(guard_selection_t *gs,
   return node;
 }
 
+/** Entry point for bridges.c to add a bridge as guard.
+ *
+ * XXXX prop271 refactor.*/
+void
+add_bridge_as_entry_guard(guard_selection_t *gs,
+                          const node_t *chosen)
+{
+  add_an_entry_guard(gs, chosen, 1, 1, 0, 0);
+}
+
 /** Choose how many entry guards or directory guards we'll use. If
  * <b>for_directory</b> is true, we return how many directory guards to
  * use; else we return how many entry guards to use. */
@@ -1490,6 +1500,19 @@ choose_random_dirguard(dirinfo_type_t type)
                                   NULL, 1, type, NULL);
 }
 
+/** Return the number of bridges that have descriptors that are marked with
+ * purpose 'bridge' and are running.
+ */
+int
+num_bridges_usable(void)
+{
+  int n_options = 0;
+  tor_assert(get_options()->UseBridges);
+  (void) choose_random_entry_impl(get_guard_selection_info(),
+                                  NULL, 0, 0, &n_options);
+  return n_options;
+}
+
 /** Filter <b>all_entry_guards</b> for usable entry guards and put them
  * in <b>live_entry_guards</b>. We filter based on whether the node is
  * currently alive, and on whether it satisfies the restrictions
diff --git a/src/or/entrynodes.h b/src/or/entrynodes.h
index 8407945..f07f843 100644
--- a/src/or/entrynodes.h
+++ b/src/or/entrynodes.h
@@ -154,6 +154,11 @@ const char *entry_guard_get_rsa_id_digest(const entry_guard_t *guard);
 const char *entry_guard_describe(const entry_guard_t *guard);
 guard_pathbias_t *entry_guard_get_pathbias_state(entry_guard_t *guard);
 
+/* Used by bridges.c only. */
+void add_bridge_as_entry_guard(guard_selection_t *gs,
+                               const node_t *chosen);
+int num_bridges_usable(void);
+
 #ifdef ENTRYNODES_PRIVATE
 STATIC time_t randomize_time(time_t now, time_t max_backdate);
 STATIC void entry_guard_add_to_sample(guard_selection_t *gs,





More information about the tor-commits mailing list