[tor-commits] [tor/master] Make circpathbias and circuitbuild compile.

nickm at torproject.org nickm at torproject.org
Thu Oct 31 18:43:26 UTC 2013


commit 5cba0ddfc46e7bc5dc7251aee1cc048ec050f280
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu Oct 31 14:28:49 2013 -0400

    Make circpathbias and circuitbuild compile.
    
    That was the tricky part
---
 src/or/circpathbias.c |   48 ++++++++++++++++++++++++++++++++++++++++++++----
 src/or/circpathbias.h |    2 ++
 src/or/circuitbuild.c |   26 --------------------------
 3 files changed, 46 insertions(+), 30 deletions(-)

diff --git a/src/or/circpathbias.c b/src/or/circpathbias.c
index 106337e..ca8db51 100644
--- a/src/or/circpathbias.c
+++ b/src/or/circpathbias.c
@@ -1,14 +1,54 @@
-
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2013, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#include "or.h"
+#include "channel.h"
 #include "circpathbias.h"
 #include "circuitbuild.h"
+#include "circuitlist.h"
+#include "circuituse.h"
+#include "circuitstats.h"
+#include "connection_edge.h"
+#include "config.h"
+#include "entrynodes.h"
+#include "networkstatus.h"
+#include "relay.h"
 
-static void pathbias_count_build_success(origin_circuit_t *circ);
 static void pathbias_count_successful_close(origin_circuit_t *circ);
 static void pathbias_count_collapse(origin_circuit_t *circ);
 static void pathbias_count_use_failed(origin_circuit_t *circ);
 static void pathbias_measure_use_rate(entry_guard_t *guard);
 static void pathbias_measure_close_rate(entry_guard_t *guard);
 static void pathbias_scale_use_rates(entry_guard_t *guard);
+static void pathbias_scale_close_rates(entry_guard_t *guard);
+static int entry_guard_inc_circ_attempt_count(entry_guard_t *guard);
+
+/** Increment the number of times we successfully extended a circuit to
+ * <b>guard</b>, first checking if the failure rate is high enough that
+ * we should eliminate the guard. Return -1 if the guard looks no good;
+ * return 0 if the guard looks fine.
+ */
+static int
+entry_guard_inc_circ_attempt_count(entry_guard_t *guard)
+{
+  entry_guards_changed();
+
+  pathbias_measure_close_rate(guard);
+
+  if (guard->path_bias_disabled)
+    return -1;
+
+  pathbias_scale_close_rates(guard);
+  guard->circ_attempts++;
+
+  log_info(LD_CIRC, "Got success count %f/%f for guard %s ($%s)",
+           guard->circ_successes, guard->circ_attempts, guard->nickname,
+           hex_str(guard->identity, DIGEST_LEN));
+  return 0;
+}
 
 /** The minimum number of circuit attempts before we start
   * thinking about warning about path bias and dropping guards */
@@ -349,7 +389,7 @@ pathbias_should_count(origin_circuit_t *circ)
  *
  * Also check for several potential error cases for bug #6475.
  */
-static int
+int
 pathbias_count_build_attempt(origin_circuit_t *circ)
 {
 #define CIRC_ATTEMPT_NOTICE_INTERVAL (600)
@@ -435,7 +475,7 @@ pathbias_count_build_attempt(origin_circuit_t *circ)
  *
  * Also check for several potential error cases for bug #6475.
  */
-static void
+void
 pathbias_count_build_success(origin_circuit_t *circ)
 {
 #define SUCCESS_NOTICE_INTERVAL (600)
diff --git a/src/or/circpathbias.h b/src/or/circpathbias.h
index bccc6f6..c95d801 100644
--- a/src/or/circpathbias.h
+++ b/src/or/circpathbias.h
@@ -16,6 +16,8 @@ double pathbias_get_extreme_rate(const or_options_t *options);
 double pathbias_get_extreme_use_rate(const or_options_t *options);
 int pathbias_get_dropguards(const or_options_t *options);
 void pathbias_count_timeout(origin_circuit_t *circ);
+void pathbias_count_build_success(origin_circuit_t *circ);
+int pathbias_count_build_attempt(origin_circuit_t *circ);
 int pathbias_check_close(origin_circuit_t *circ, int reason);
 int pathbias_check_probe_response(circuit_t *circ, const cell_t *cell);
 void pathbias_count_use_attempt(origin_circuit_t *circ);
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 96792b1..a120b46 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -41,7 +41,6 @@
 #include "routerparse.h"
 #include "routerset.h"
 #include "crypto.h"
-#include "connection_edge.h"
 
 #ifndef MIN
 #define MIN(a,b) ((a)<(b)?(a):(b))
@@ -58,7 +57,6 @@ static crypt_path_t *onion_next_hop_in_cpath(crypt_path_t *cpath);
 static int onion_extend_cpath(origin_circuit_t *circ);
 static int count_acceptable_nodes(smartlist_t *routers);
 static int onion_append_hop(crypt_path_t **head_ptr, extend_info_t *choice);
-static int entry_guard_inc_circ_attempt_count(entry_guard_t *guard);
 
 /** This function tries to get a channel to the specified endpoint,
  * and then calls command_setup_channel() to give it the right
@@ -1078,30 +1076,6 @@ circuit_init_cpath_crypto(crypt_path_t *cpath, const char *key_data,
   return 0;
 }
 
-/** Increment the number of times we successfully extended a circuit to
- * <b>guard</b>, first checking if the failure rate is high enough that
- * we should eliminate the guard. Return -1 if the guard looks no good;
- * return 0 if the guard looks fine.
- */
-static int
-entry_guard_inc_circ_attempt_count(entry_guard_t *guard)
-{
-  entry_guards_changed();
-
-  pathbias_measure_close_rate(guard);
-
-  if (guard->path_bias_disabled)
-    return -1;
-
-  pathbias_scale_close_rates(guard);
-  guard->circ_attempts++;
-
-  log_info(LD_CIRC, "Got success count %f/%f for guard %s ($%s)",
-           guard->circ_successes, guard->circ_attempts, guard->nickname,
-           hex_str(guard->identity, DIGEST_LEN));
-  return 0;
-}
-
 /** A "created" cell <b>reply</b> came back to us on circuit <b>circ</b>.
  * (The body of <b>reply</b> varies depending on what sort of handshake
  * this is.)





More information about the tor-commits mailing list