Quellcode durchsuchen

Rename has_completed_circuit to can_complete_circuit

Also redocument it.  Related to #1362.
Nick Mathewson vor 13 Jahren
Ursprung
Commit
c9cb4f0a0e
7 geänderte Dateien mit 18 neuen und 14 gelöschten Zeilen
  1. 3 3
      src/or/circuitbuild.c
  2. 1 1
      src/or/config.c
  3. 1 1
      src/or/control.c
  4. 1 1
      src/or/directory.c
  5. 10 6
      src/or/main.c
  6. 1 1
      src/or/main.h
  7. 1 1
      src/or/routerlist.c

+ 3 - 3
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();

+ 1 - 1
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();

+ 1 - 1
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") ||

+ 1 - 1
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 ||

+ 10 - 6
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) {

+ 1 - 1
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);

+ 1 - 1
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");
   }