diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-10-31 14:28:49 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-10-31 14:28:49 -0400 |
commit | 5cba0ddfc46e7bc5dc7251aee1cc048ec050f280 (patch) | |
tree | c5ef0c87a6d60c6291f1bd686d090543bb373d95 /src/or/circpathbias.c | |
parent | b4ebf8421ada3edf104ae5fc96d288f11271445b (diff) | |
download | tor-5cba0ddfc46e7bc5dc7251aee1cc048ec050f280.tar.gz tor-5cba0ddfc46e7bc5dc7251aee1cc048ec050f280.zip |
Make circpathbias and circuitbuild compile.
That was the tricky part
Diffstat (limited to 'src/or/circpathbias.c')
-rw-r--r-- | src/or/circpathbias.c | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/src/or/circpathbias.c b/src/or/circpathbias.c index 106337e019..ca8db514fb 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) |