[tor-commits] [tor/master] Make control_event_bootstrap() return void

nickm at torproject.org nickm at torproject.org
Tue Sep 11 19:55:44 UTC 2018


commit eee62e13d97e3f07c0d8577f34729f4192738b44
Author: Taylor Yu <catalyst at torproject.org>
Date:   Tue Aug 28 13:30:58 2018 -0500

    Make control_event_bootstrap() return void
    
    Simplify control_event_bootstrap() by making it return void again.  It
    is currently a fairly complicated function, and it's made more
    complicated by returning an int to signal whether it logged at NOTICE
    or INFO.
    
    The callers conditionally log messages at level NOTICE based on this
    return value.  Change the callers to unconditionally log their verbose
    human-readable messages at level INFO to keep NOTICE logs less
    cluttered.
    
    This partially reverts the changes of #14950.
---
 src/core/or/circuitbuild.c      | 12 ++++--------
 src/feature/control/control.c   |  9 ++-------
 src/feature/control/control.h   |  2 +-
 src/feature/nodelist/nodelist.c |  7 +++----
 4 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/src/core/or/circuitbuild.c b/src/core/or/circuitbuild.c
index 7d8052397..3693b8b2c 100644
--- a/src/core/or/circuitbuild.c
+++ b/src/core/or/circuitbuild.c
@@ -1051,14 +1051,10 @@ circuit_build_no_more_hops(origin_circuit_t *circ)
     const or_options_t *options = get_options();
     note_that_we_completed_a_circuit();
     /* FFFF Log a count of known routers here */
-    log_notice(LD_GENERAL,
-               "Tor has successfully opened a circuit. "
-               "Looks like client functionality is working.");
-    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.");
-    }
+    log_info(LD_GENERAL,
+             "Tor has successfully opened a circuit. "
+             "Looks like client functionality is working.");
+    control_event_bootstrap(BOOTSTRAP_STATUS_DONE, 0);
     control_event_client_status(LOG_NOTICE, "CIRCUIT_ESTABLISHED");
     clear_broken_connection_map(1);
     if (server_mode(options) && !check_whether_orport_reachable(options)) {
diff --git a/src/feature/control/control.c b/src/feature/control/control.c
index 9e7d21308..84ff7d71d 100644
--- a/src/feature/control/control.c
+++ b/src/feature/control/control.c
@@ -7101,17 +7101,15 @@ 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.
- *
- * Return true if we logged a message at level NOTICE, and false otherwise.
  */
-int
+void
 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 0; /* already bootstrapped; nothing to be done here. */
+    return; /* 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. */
@@ -7158,10 +7156,7 @@ 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/feature/control/control.h b/src/feature/control/control.h
index 5c5fe8a91..7f57228e5 100644
--- a/src/feature/control/control.h
+++ b/src/feature/control/control.h
@@ -191,7 +191,7 @@ void enable_control_logging(void);
 
 void monitor_owning_controller_process(const char *process_spec);
 
-int control_event_bootstrap(bootstrap_status_t status, int progress);
+void control_event_bootstrap(bootstrap_status_t status, int progress);
 MOCK_DECL(void, control_event_bootstrap_prob_or,(const char *warn,
                                                  int reason,
                                                  or_connection_t *or_conn));
diff --git a/src/feature/nodelist/nodelist.c b/src/feature/nodelist/nodelist.c
index e62e87ea7..6dd501ea3 100644
--- a/src/feature/nodelist/nodelist.c
+++ b/src/feature/nodelist/nodelist.c
@@ -2553,10 +2553,9 @@ update_router_have_minimum_dir_info(void)
   /* If paths have just become available in this update. */
   if (res && !have_min_dir_info) {
     control_event_client_status(LOG_NOTICE, "ENOUGH_DIR_INFO");
-    if (control_event_bootstrap(BOOTSTRAP_STATUS_CONN_OR, 0) == 0) {
-      log_notice(LD_DIR,
-              "We now have enough directory information to build circuits.");
-    }
+    control_event_bootstrap(BOOTSTRAP_STATUS_CONN_OR, 0);
+    log_info(LD_DIR,
+             "We now have enough directory information to build circuits.");
   }
 
   /* If paths have just become unavailable in this update. */





More information about the tor-commits mailing list