[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Fix a rather serious use-count state bug.



commit b75880d7b3d02f5c60bf2e215c6e84da4f3e1938
Author: Mike Perry <mikeperry-git@xxxxxxxxxx>
Date:   Sun Dec 9 20:56:48 2012 -0800

    Fix a rather serious use-count state bug.
    
    We need to use the success count or the use count depending on the consensus
    parameter.
---
 src/or/circuitbuild.c |    2 +-
 src/or/entrynodes.c   |    4 ++--
 src/or/entrynodes.h   |    1 +
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index cbc1af9..349063d 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -1642,7 +1642,7 @@ pathbias_get_closed_count(entry_guard_t *guard)
  * if it should return guard->circ_successes or
  * guard->successful_circuits_closed.
  */
-static double 
+double 
 pathbias_get_success_count(entry_guard_t *guard)
 {
   if (pathbias_use_close_counts(get_options())) {
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 21c09f7..96b075a 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -1065,8 +1065,8 @@ entry_guards_parse_state(or_state_t *state, int set, char **msg)
       /* Note: We rely on the < comparison here to allow us to set a 0
        * rate and disable the feature entirely. If refactoring, don't
        * change to <= */
-      if ((node->circ_successes/((double)node->circ_attempts)
-          < pathbias_get_extreme_rate(options)) &&
+      if (pathbias_get_success_count(node)/node->circ_attempts
+            < pathbias_get_extreme_rate(options) &&
           pathbias_get_dropguards(options)) {
         node->path_bias_disabled = 1;
         log_info(LD_GENERAL,
diff --git a/src/or/entrynodes.h b/src/or/entrynodes.h
index de8c60c..b9d0e55 100644
--- a/src/or/entrynodes.h
+++ b/src/or/entrynodes.h
@@ -112,6 +112,7 @@ int find_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port,
 int validate_pluggable_transports_config(void);
 
 double pathbias_get_closed_count(entry_guard_t *gaurd);
+double pathbias_get_success_count(entry_guard_t *guard);
 
 #endif
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits