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

[tor-commits] [tor/master] Comment-only fix: annotate we_are_hibernating() usage



commit c0feb698a0ab8574019d23cbd3060eb0513489c4
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Wed May 9 12:18:04 2018 -0400

    Comment-only fix: annotate we_are_hibernating() usage
    
    Everywhere we use we_are_hibernating(), remind the reader what it
    means.
    
    (Also, add an XXXX to note a DisableNetwork usage to change later.)
---
 src/or/config.c          | 6 +++---
 src/or/connection.c      | 2 +-
 src/or/connection_edge.c | 1 +
 src/or/control.c         | 2 ++
 src/or/dirserv.c         | 2 +-
 src/or/main.c            | 3 ++-
 src/or/router.c          | 3 +++
 7 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/or/config.c b/src/or/config.c
index 9af613e93..e695947f0 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1449,9 +1449,9 @@ options_act_reversible(const or_options_t *old_options, char **msg)
     consider_hibernation(time(NULL));
 
     /* Launch the listeners.  (We do this before we setuid, so we can bind to
-     * ports under 1024.)  We don't want to rebind if we're hibernating. If
-     * networking is disabled, this will close all but the control listeners,
-     * but disable those. */
+     * ports under 1024.)  We don't want to rebind if we're hibernating or
+     * shutting down. If networking is disabled, this will close all but the
+     * control listeners, but disable those. */
     if (!we_are_hibernating()) {
       if (retry_all_listeners(replaced_listeners, new_listeners,
                               options->DisableNetwork) < 0) {
diff --git a/src/or/connection.c b/src/or/connection.c
index 4361e1ca0..9b7e15243 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -1762,7 +1762,7 @@ connection_connect_sockaddr,(connection_t *conn,
   tor_assert(sa);
   tor_assert(socket_error);
 
-  if (get_options()->DisableNetwork) {
+  if (get_options()->DisableNetwork) { // XXXX change this -NM.
     /* We should never even try to connect anyplace if DisableNetwork is set.
      * Warn if we do, and refuse to make the connection.
      *
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 5ae1538bf..28e18aa85 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -3537,6 +3537,7 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
   n_stream->base_.state = EXIT_CONN_STATE_RESOLVEFAILED;
   /* default to failed, change in dns_resolve if it turns out not to fail */
 
+  /* If we're hibernating or shutting down, we refuse to open new streams. */
   if (we_are_hibernating()) {
     relay_send_end_cell_from_edge(rh.stream_id, circ,
                                   END_STREAM_REASON_HIBERNATING, NULL);
diff --git a/src/or/control.c b/src/or/control.c
index d653a520b..44439b6d5 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -7107,6 +7107,8 @@ control_event_bootstrap_problem(const char *warn, const char *reason,
   if (bootstrap_problems >= BOOTSTRAP_PROBLEM_THRESHOLD)
     dowarn = 1;
 
+  /* Don't warn about our bootstrapping status if we are hibernating or
+   * shutting down. */
   if (we_are_hibernating())
     dowarn = 0;
 
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index bfcec6e10..c01234e0b 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -955,7 +955,7 @@ dirserv_set_router_is_running(routerinfo_t *router, time_t now)
   tor_assert(node);
 
   if (router_is_me(router)) {
-    /* We always know if we are down ourselves. */
+    /* We always know if we are shutting down or hibernating ourselves. */
     answer = ! we_are_hibernating();
   } else if (router->is_hibernating &&
              (router->cache_info.published_on +
diff --git a/src/or/main.c b/src/or/main.c
index 8929931eb..682ec29ab 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1253,7 +1253,8 @@ run_connection_housekeeping(int i, time_t now)
   } else if (we_are_hibernating() &&
              ! have_any_circuits &&
              !connection_get_outbuf_len(conn)) {
-    /* We're hibernating, there's no circuits, and nothing to flush.*/
+    /* We're hibernating or shutting down, there's no circuits, and nothing to
+     * flush.*/
     log_info(LD_OR,"Expiring non-used OR connection to fd %d (%s:%d) "
              "[Hibernating or exiting].",
              (int)conn->s,conn->address, conn->port);
diff --git a/src/or/router.c b/src/or/router.c
index 996a28a91..71b292a67 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -2268,6 +2268,7 @@ router_build_fresh_descriptor(routerinfo_t **r, extrainfo_t **e)
   /* and compute ri->bandwidthburst similarly */
   ri->bandwidthburst = get_effective_bwburst(options);
 
+  /* Report bandwidth, unless we're hibernating or shutting down */
   ri->bandwidthcapacity = hibernating ? 0 : rep_hist_bandwidth_assess();
 
   if (dns_seems_to_be_broken() || has_dns_init_failed()) {
@@ -2538,6 +2539,8 @@ check_descriptor_bandwidth_changed(time_t now)
     return;
 
   prev = router_get_my_routerinfo()->bandwidthcapacity;
+  /* Consider ourselves to have zero bandwidth if we're hibernating or
+   * shutting down. */
   cur = we_are_hibernating() ? 0 : rep_hist_bandwidth_assess();
   if ((prev != cur && (!prev || !cur)) ||
       cur > prev*2 ||



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