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

[tor-commits] [tor/master] Move cbt->liveness.timeouts_after_firsthop free code into its own function



commit aa284561c804085ab2bb3e414165fdeff9872d05
Author: Andrea Shepard <andrea@xxxxxxxxxxxxxxxxxxx>
Date:   Tue Jun 12 19:27:37 2012 -0700

    Move cbt->liveness.timeouts_after_firsthop free code into its own function
---
 src/or/circuitbuild.c |   29 +++++++++++++++++------------
 src/or/circuitbuild.h |    1 +
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 03b702b..4f46022 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -493,12 +493,7 @@ circuit_build_times_new_consensus_params(circuit_build_times_t *cbt,
                "This disables adaptive timeouts since we can't keep track of "
                "any recent circuits.");
 
-      if (cbt->liveness.timeouts_after_firsthop) {
-        tor_free(cbt->liveness.timeouts_after_firsthop);
-        cbt->liveness.timeouts_after_firsthop = NULL;
-      }
-
-      cbt->liveness.num_recent_circs = num;
+      circuit_build_times_free_timeouts(cbt);
     }
   } else {
     /*
@@ -509,12 +504,7 @@ circuit_build_times_new_consensus_params(circuit_build_times_t *cbt,
      * if we have any.
      */
 
-    if (cbt->liveness.timeouts_after_firsthop) {
-      tor_free(cbt->liveness.timeouts_after_firsthop);
-      cbt->liveness.timeouts_after_firsthop = NULL;
-    }
-
-    cbt->liveness.num_recent_circs = 0;
+    circuit_build_times_free_timeouts(cbt);
   }
 }
 
@@ -598,6 +588,21 @@ circuit_build_times_init(circuit_build_times_t *cbt)
   control_event_buildtimeout_set(cbt, BUILDTIMEOUT_SET_EVENT_RESET);
 }
 
+/**
+ * Free the saved timeouts, if the cbtdisabled consensus parameter got turned
+ * on or something.
+ */
+
+void circuit_build_times_free_timeouts(circuit_build_times_t *cbt) {
+  if (!cbt) return;
+
+  if (cbt->liveness.timeouts_after_firsthop) {
+    tor_free(cbt->liveness.timeouts_after_firsthop);
+  }
+
+  cbt->liveness.num_recent_circs = 0;
+}
+
 #if 0
 /**
  * Rewind our build time history by n positions.
diff --git a/src/or/circuitbuild.h b/src/or/circuitbuild.h
index 5b77399..9281178 100644
--- a/src/or/circuitbuild.h
+++ b/src/or/circuitbuild.h
@@ -121,6 +121,7 @@ int circuit_build_times_needs_circuits(circuit_build_times_t *cbt);
 
 int circuit_build_times_needs_circuits_now(circuit_build_times_t *cbt);
 void circuit_build_times_init(circuit_build_times_t *cbt);
+void circuit_build_times_free_timeouts(circuit_build_times_t *cbt);
 void circuit_build_times_new_consensus_params(circuit_build_times_t *cbt,
                                               networkstatus_t *ns);
 double circuit_build_times_timeout_rate(const circuit_build_times_t *cbt);



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