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

[tor-commits] [tor/master] Avoid logging natural-language reports that are redundant with bootstrapping



commit d221b507c9b014039a94aa91bed082689342e347
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Fri Feb 20 02:03:42 2015 -0500

    Avoid logging natural-language reports that are redundant with bootstrapping
---
 src/or/circuitbuild.c |    6 +++++-
 src/or/control.c      |   12 +++++++++---
 src/or/control.h      |    2 +-
 src/or/nodelist.c     |    7 ++++---
 4 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 57056b2..946c002 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -960,7 +960,11 @@ circuit_send_next_onion_skin(origin_circuit_t *circ)
         log_notice(LD_GENERAL,
             "Tor has successfully opened a circuit. "
             "Looks like client functionality is working.");
-        control_event_bootstrap(BOOTSTRAP_STATUS_DONE, 0);
+        if (control_event_bootstrap(BOOTSTRAP_STATUS_DONE, 0) == 0) {
+          log_notice(LD_GENERAL,
+                     "Tor has successfully opened a circuit. "
+                     "Looks like client functionality is working.");
+        }
         control_event_client_status(LOG_NOTICE, "CIRCUIT_ESTABLISHED");
         clear_broken_connection_map(1);
         if (server_mode(options) && !check_whether_orport_reachable()) {
diff --git a/src/or/control.c b/src/or/control.c
index 064b745..a2b9867 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -4971,15 +4971,18 @@ static int bootstrap_problems = 0;
  *
  * <b>status</b> is the new status, that is, what task we will be doing
  * next. <b>progress</b> is zero if we just started this task, else it
- * represents progress on the task. */
-void
+ * represents progress on the task.
+ *
+ * Return true if we logged a message at level NOTICE, and false otherwise.
+ */
+int
 control_event_bootstrap(bootstrap_status_t status, int progress)
 {
   const char *tag, *summary;
   char buf[BOOTSTRAP_MSG_LEN];
 
   if (bootstrap_percent == BOOTSTRAP_STATUS_DONE)
-    return; /* already bootstrapped; nothing to be done here. */
+    return 0; /* already bootstrapped; nothing to be done here. */
 
   /* special case for handshaking status, since our TLS handshaking code
    * can't distinguish what the connection is going to be for. */
@@ -5026,7 +5029,10 @@ control_event_bootstrap(bootstrap_status_t status, int progress)
       /* Remember that we gave a notice at this level. */
       notice_bootstrap_percent = bootstrap_percent;
     }
+    return loglevel == LOG_NOTICE;
   }
+
+  return 0;
 }
 
 /** Called when Tor has failed to make bootstrapping progress in a way
diff --git a/src/or/control.h b/src/or/control.h
index 8c9f7bb..47a6018 100644
--- a/src/or/control.h
+++ b/src/or/control.h
@@ -92,7 +92,7 @@ void enable_control_logging(void);
 
 void monitor_owning_controller_process(const char *process_spec);
 
-void control_event_bootstrap(bootstrap_status_t status, int progress);
+int control_event_bootstrap(bootstrap_status_t status, int progress);
 MOCK_DECL(void, control_event_bootstrap_problem,(const char *warn,
                                                  int reason,
                                                  or_connection_t *or_conn));
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index 23d7a06..8f8adb4 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -1698,10 +1698,11 @@ update_router_have_minimum_dir_info(void)
 
   /* If paths have just become available in this update. */
   if (res && !have_min_dir_info) {
-    log_notice(LD_DIR,
-        "We now have enough directory information to build circuits.");
     control_event_client_status(LOG_NOTICE, "ENOUGH_DIR_INFO");
-    control_event_bootstrap(BOOTSTRAP_STATUS_CONN_OR, 0);
+    if (control_event_bootstrap(BOOTSTRAP_STATUS_CONN_OR, 0) == 0) {
+      log_notice(LD_DIR,
+              "We now have enough directory information to build circuits.");
+    }
   }
 
   /* If paths have just become unavailable in this update. */



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