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

[or-cvs] [tor/master 2/2] Rename has_completed_circuit to can_complete_circuit



Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Wed, 22 Sep 2010 01:52:57 -0400
Subject: Rename has_completed_circuit to can_complete_circuit
Commit: c9cb4f0a0e9eb3411dfdc446e4543d48b152f8f5

Also redocument it.  Related to #1362.
---
 src/or/circuitbuild.c |    6 +++---
 src/or/config.c       |    2 +-
 src/or/control.c      |    2 +-
 src/or/directory.c    |    2 +-
 src/or/main.c         |   16 ++++++++++------
 src/or/main.h         |    2 +-
 src/or/routerlist.c   |    2 +-
 7 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 14b0fb9..35d8087 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -1918,9 +1918,9 @@ circuit_send_next_onion_skin(origin_circuit_t *circ)
       circuit_reset_failure_count(0);
       if (circ->build_state->onehop_tunnel)
         control_event_bootstrap(BOOTSTRAP_STATUS_REQUESTING_STATUS, 0);
-      if (!has_completed_circuit && !circ->build_state->onehop_tunnel) {
+      if (!can_complete_circuit && !circ->build_state->onehop_tunnel) {
         or_options_t *options = get_options();
-        has_completed_circuit=1;
+        can_complete_circuit=1;
         /* FFFF Log a count of known routers here */
         log_notice(LD_GENERAL,
             "Tor has successfully opened a circuit. "
@@ -1987,7 +1987,7 @@ circuit_note_clock_jumped(int seconds_elapsed)
       seconds_elapsed >=0 ? "forward" : "backward");
   control_event_general_status(LOG_WARN, "CLOCK_JUMPED TIME=%d",
                                seconds_elapsed);
-  has_completed_circuit=0; /* so it'll log when it works again */
+  can_complete_circuit=0; /* so it'll log when it works again */
   control_event_client_status(severity, "CIRCUIT_NOT_ESTABLISHED REASON=%s",
                               "CLOCK_JUMPED");
   circuit_mark_all_unused_circs();
diff --git a/src/or/config.c b/src/or/config.c
index 73b96fd..8febe7a 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1290,7 +1290,7 @@ options_act(or_options_t *old_options)
           return -1;
         }
         ip_address_changed(0);
-        if (has_completed_circuit || !any_predicted_circuits(time(NULL)))
+        if (can_complete_circuit || !any_predicted_circuits(time(NULL)))
           inform_testing_reachability();
       }
       cpuworkers_rotate();
diff --git a/src/or/control.c b/src/or/control.c
index 7eead0e..4d505a9 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -1726,7 +1726,7 @@ getinfo_helper_events(control_connection_t *control_conn,
     /* Note that status/ is not a catch-all for events; there's only supposed
      * to be a status GETINFO if there's a corresponding STATUS event. */
     if (!strcmp(question, "status/circuit-established")) {
-      *answer = tor_strdup(has_completed_circuit ? "1" : "0");
+      *answer = tor_strdup(can_complete_circuit ? "1" : "0");
     } else if (!strcmp(question, "status/enough-dir-info")) {
       *answer = tor_strdup(router_have_minimum_dir_info() ? "1" : "0");
     } else if (!strcmp(question, "status/good-server-descriptor") ||
diff --git a/src/or/directory.c b/src/or/directory.c
index ffa312b..b109cb5 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -126,7 +126,7 @@ purpose_needs_anonymity(uint8_t dir_purpose, uint8_t router_purpose)
 {
   if (get_options()->AllDirActionsPrivate)
     return 1;
-  if (router_purpose == ROUTER_PURPOSE_BRIDGE && has_completed_circuit)
+  if (router_purpose == ROUTER_PURPOSE_BRIDGE && can_complete_circuit)
     return 1; /* if no circuits yet, we may need this info to bootstrap. */
   if (dir_purpose == DIR_PURPOSE_UPLOAD_DIR ||
       dir_purpose == DIR_PURPOSE_UPLOAD_VOTE ||
diff --git a/src/or/main.c b/src/or/main.c
index f33dc2f..477a274 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -119,8 +119,12 @@ static smartlist_t *active_linked_connection_lst = NULL;
 static int called_loop_once = 0;
 
 /** We set this to 1 when we've opened a circuit, so we can print a log
- * entry to inform the user that Tor is working. */
-int has_completed_circuit=0;
+ * entry to inform the user that Tor is working.  We set it to 0 when
+ * we think the fact that we once opened a circuit doesn't mean we can do so
+ * any longer (a big time jump happened, when we notice our directory is
+ * heinously out-of-date, etc.
+ */
+int can_complete_circuit=0;
 
 /** How often do we check for router descriptors that we should download
  * when we have too little directory info? */
@@ -714,7 +718,7 @@ directory_info_has_arrived(time_t now, int from_cache)
   }
 
   if (server_mode(options) && !we_are_hibernating() && !from_cache &&
-      (has_completed_circuit || !any_predicted_circuits(now)))
+      (can_complete_circuit || !any_predicted_circuits(now)))
     consider_testing_reachability(1, 1);
 }
 
@@ -1093,7 +1097,7 @@ run_scheduled_events(time_t now)
     /* also, check religiously for reachability, if it's within the first
      * 20 minutes of our uptime. */
     if (server_mode(options) &&
-        (has_completed_circuit || !any_predicted_circuits(now)) &&
+        (can_complete_circuit || !any_predicted_circuits(now)) &&
         !we_are_hibernating()) {
       if (stats_n_seconds_working < TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT) {
         consider_testing_reachability(1, dirport_reachability_count==0);
@@ -1192,7 +1196,7 @@ run_scheduled_events(time_t now)
   circuit_close_all_marked();
 
   /** 7. And upload service descriptors if necessary. */
-  if (has_completed_circuit && !we_are_hibernating()) {
+  if (can_complete_circuit && !we_are_hibernating()) {
     rend_consider_services_upload(now);
     rend_consider_descriptor_republication();
   }
@@ -1274,7 +1278,7 @@ second_elapsed_callback(periodic_timer_t *timer, void *arg)
   if (server_mode(options) &&
       !we_are_hibernating() &&
       seconds_elapsed > 0 &&
-      has_completed_circuit &&
+      can_complete_circuit &&
       stats_n_seconds_working / TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT !=
       (stats_n_seconds_working+seconds_elapsed) /
         TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT) {
diff --git a/src/or/main.h b/src/or/main.h
index 6eeb954..ef38dc9 100644
--- a/src/or/main.h
+++ b/src/or/main.h
@@ -12,7 +12,7 @@
 #ifndef _TOR_MAIN_H
 #define _TOR_MAIN_H
 
-extern int has_completed_circuit;
+extern int can_complete_circuit;
 
 int connection_add(connection_t *conn);
 int connection_remove(connection_t *conn);
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index ca5ec3e..5fb4fe1 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -4810,7 +4810,7 @@ update_router_have_minimum_dir_info(void)
      * is back up and usable, and b) disable some activities that Tor
      * should only do while circuits are working, like reachability tests
      * and fetching bridge descriptors only over circuits. */
-    has_completed_circuit = 0;
+    can_complete_circuit = 0;
 
     control_event_client_status(LOG_NOTICE, "NOT_ENOUGH_DIR_INFO");
   }
-- 
1.7.1