[or-cvs] [tor/master 05/15] Rename routerstatus_t.is_running to is_flagged_running

nickm at torproject.org nickm at torproject.org
Wed Oct 13 19:59:50 UTC 2010


Author: Nick Mathewson <nickm at torproject.org>
Date: Thu, 30 Sep 2010 14:58:27 -0400
Subject: Rename routerstatus_t.is_running to is_flagged_running
Commit: 45f1e4d5ee7b6e2308655628d18a67d330d9b624

This was the only flag in routerstatus_t that we would previously
change in a routerstatus_t in a consensus. We no longer have reason
to do so -- and probably never did -- as you can now confirm more
easily than you could have done by grepping for is_running before
this patch.

The name change is to emphasize that the routerstatus_t is_running
flag is only there to tell you whether the consensus says it's
running, not whether it *you* think it's running.
---
 src/or/dirserv.c       |    8 ++++----
 src/or/networkstatus.c |    4 ++--
 src/or/nodelist.c      |    2 +-
 src/or/or.h            |    6 +++++-
 src/or/routerlist.c    |   11 ++++++-----
 src/or/routerparse.c   |    2 +-
 src/test/test_dir.c    |   12 +++++++-----
 7 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index dec1577..24718a1 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -2035,7 +2035,7 @@ routerstatus_format_entry(char *buf, size_t buf_len,
                    rs->is_possible_guard?" Guard":"",
                    rs->is_hs_dir?" HSDir":"",
                    rs->is_named?" Named":"",
-                   rs->is_running?" Running":"",
+                   rs->is_flagged_running?" Running":"",
                    rs->is_stable?" Stable":"",
                    rs->is_unnamed?" Unnamed":"",
                    rs->is_v2_dir?" V2Dir":"",
@@ -2275,7 +2275,7 @@ set_routerstatus_from_routerinfo(routerstatus_t *rs,
   rs->is_fast = node->is_fast =
     router_is_active(ri, node, now) &&
     !dirserv_thinks_router_is_unreliable(now, ri, 0, 1);
-  rs->is_running = node->is_running; /* computed above */
+  rs->is_flagged_running = node->is_running; /* computed above */
 
   if (naming) {
     uint32_t name_status = dirserv_get_name_status(
@@ -2323,7 +2323,7 @@ static void
 clear_status_flags_on_sybil(routerstatus_t *rs)
 {
   rs->is_authority = rs->is_exit = rs->is_stable = rs->is_fast =
-    rs->is_running = rs->is_named = rs->is_valid = rs->is_v2_dir =
+    rs->is_flagged_running = rs->is_named = rs->is_valid = rs->is_v2_dir =
     rs->is_hs_dir = rs->is_possible_guard = rs->is_bad_exit =
     rs->is_bad_directory = 0;
   /* FFFF we might want some mechanism to check later on if we
@@ -2591,7 +2591,7 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_env_t *private_key,
         clear_status_flags_on_sybil(rs);
 
       if (!vote_on_reachability)
-        rs->is_running = 0;
+        rs->is_flagged_running = 0;
 
       vrs->version = version_from_platform(ri->platform);
       md = dirvote_create_microdescriptor(ri);
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 7374ced..2a3fb83 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -1475,7 +1475,7 @@ routerstatus_has_changed(const routerstatus_t *a, const routerstatus_t *b)
          a->is_exit != b->is_exit ||
          a->is_stable != b->is_stable ||
          a->is_fast != b->is_fast ||
-         a->is_running != b->is_running ||
+         a->is_flagged_running != b->is_flagged_running ||
          a->is_named != b->is_named ||
          a->is_unnamed != b->is_unnamed ||
          a->is_valid != b->is_valid ||
@@ -2022,7 +2022,7 @@ routers_update_status_from_consensus_networkstatus(smartlist_t *routers,
           dirserv_should_launch_reachability_test(router, old_router);
       }
     }
-    if (rs->is_running && ds) {
+    if (rs->is_flagged_running && ds) {
       download_status_reset(&ds->v2_ns_dl_status);
     }
     if (reset_failures) {
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index f2923a4..dd83abf 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -193,7 +193,7 @@ nodelist_set_consensus(networkstatus_t *ns)
     /* If we're not an authdir, believe others. */
     if (!authdir) {
       node->is_valid = rs->is_valid;
-      node->is_running = rs->is_running;
+      node->is_running = rs->is_flagged_running;
       node->is_fast = rs->is_fast;
       node->is_stable = rs->is_stable;
       node->is_possible_guard = rs->is_possible_guard;
diff --git a/src/or/or.h b/src/or/or.h
index d9be013..670cf7d 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1586,7 +1586,11 @@ typedef struct routerstatus_t {
   unsigned int is_exit:1; /**< True iff this router is a good exit. */
   unsigned int is_stable:1; /**< True iff this router stays up a long time. */
   unsigned int is_fast:1; /**< True iff this router has good bandwidth. */
-  unsigned int is_running:1; /**< True iff this router is up. */
+  /** True iff this router is called 'running' in the consensus. We give it
+   * this funny name so that we don't accidentally use this bit as a view of
+   * whether we think the router is *currently* running.  If that's what you
+   * want to know, look at is_running in node_t. */
+  unsigned int is_flagged_running:1;
   unsigned int is_named:1; /**< True iff "nickname" belongs to this router. */
   unsigned int is_unnamed:1; /**< True iff "nickname" belongs to another
                               * router. */
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index e456f43..a082ff4 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -1276,8 +1276,7 @@ mark_all_trusteddirservers_up(void)
       dir->is_running = 1;
       download_status_reset(&dir->v2_ns_dl_status);
       rs = router_get_mutable_consensus_status_by_id(dir->digest);
-      if (rs && !rs->is_running) {
-        rs->is_running = 1;
+      if (rs) {
         rs->last_dir_503_at = 0;
         control_event_networkstatus_changed_single(rs);
       }
@@ -3186,7 +3185,6 @@ void
 router_set_status(const char *digest, int up)
 {
   node_t *node;
-  routerstatus_t *status;
   tor_assert(digest);
 
   SMARTLIST_FOREACH(trusted_dir_servers, trusted_dir_server_t *, d,
@@ -3207,12 +3205,15 @@ router_set_status(const char *digest, int up)
     node->is_running = up;
   }
 
-  /*XXXX NM don't change routerstatus's is_running. */
+#if 0
+  /* No, don't change routerstatus's is_running.  I have confirmed that
+   * nothing uses it to ask "is the node running? */
   status = router_get_mutable_consensus_status_by_id(digest);
   if (status && status->is_running != up) {
     status->is_running = up;
     control_event_networkstatus_changed_single(status);
   }
+#endif
   router_dir_info_changed();
 }
 
@@ -4237,7 +4238,7 @@ initiate_descriptor_downloads(const routerstatus_t *source,
 static INLINE int
 client_would_use_router(routerstatus_t *rs, time_t now, or_options_t *options)
 {
-  if (!rs->is_running && !options->FetchUselessDescriptors) {
+  if (!rs->is_flagged_running && !options->FetchUselessDescriptors) {
     /* If we had this router descriptor, we wouldn't even bother using it.
      * But, if we want to have a complete list, fetch it anyway. */
     return 0;
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index b987d6f..665a718 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -2027,7 +2027,7 @@ routerstatus_parse_entry_from_string(memarea_t *area,
       else if (!strcmp(tok->args[i], "Fast"))
         rs->is_fast = 1;
       else if (!strcmp(tok->args[i], "Running"))
-        rs->is_running = 1;
+        rs->is_flagged_running = 1;
       else if (!strcmp(tok->args[i], "Named"))
         rs->is_named = 1;
       else if (!strcmp(tok->args[i], "Valid"))
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index 80d2379..3c660a7 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -801,7 +801,7 @@ test_dir_v3_networkstatus(void)
   rs->or_port = 443;
   rs->dir_port = 8000;
   /* all flags but running cleared */
-  rs->is_running = 1;
+  rs->is_flagged_running = 1;
   smartlist_add(vote->routerstatus_list, vrs);
   test_assert(router_add_to_routerlist(generate_ri_from_rs(vrs), &msg,0,0)>=0);
 
@@ -816,7 +816,7 @@ test_dir_v3_networkstatus(void)
   rs->addr = 0x99009901;
   rs->or_port = 443;
   rs->dir_port = 0;
-  rs->is_exit = rs->is_stable = rs->is_fast = rs->is_running =
+  rs->is_exit = rs->is_stable = rs->is_fast = rs->is_flagged_running =
     rs->is_valid = rs->is_v2_dir = rs->is_possible_guard = 1;
   smartlist_add(vote->routerstatus_list, vrs);
   test_assert(router_add_to_routerlist(generate_ri_from_rs(vrs), &msg,0,0)>=0);
@@ -833,7 +833,8 @@ test_dir_v3_networkstatus(void)
   rs->or_port = 400;
   rs->dir_port = 9999;
   rs->is_authority = rs->is_exit = rs->is_stable = rs->is_fast =
-    rs->is_running = rs->is_valid = rs->is_v2_dir = rs->is_possible_guard = 1;
+    rs->is_flagged_running = rs->is_valid = rs->is_v2_dir =
+    rs->is_possible_guard = 1;
   smartlist_add(vote->routerstatus_list, vrs);
   test_assert(router_add_to_routerlist(generate_ri_from_rs(vrs), &msg,0,0)>=0);
 
@@ -1073,7 +1074,8 @@ test_dir_v3_networkstatus(void)
   test_assert(!rs->is_fast);
   test_assert(!rs->is_possible_guard);
   test_assert(!rs->is_stable);
-  test_assert(rs->is_running); /* If it wasn't running it wouldn't be here */
+  /* (If it wasn't running it wouldn't be here) */
+  test_assert(rs->is_flagged_running);
   test_assert(!rs->is_v2_dir);
   test_assert(!rs->is_valid);
   test_assert(!rs->is_named);
@@ -1095,7 +1097,7 @@ test_dir_v3_networkstatus(void)
   test_assert(rs->is_fast);
   test_assert(rs->is_possible_guard);
   test_assert(rs->is_stable);
-  test_assert(rs->is_running);
+  test_assert(rs->is_flagged_running);
   test_assert(rs->is_v2_dir);
   test_assert(rs->is_valid);
   test_assert(!rs->is_named);
-- 
1.7.1




More information about the tor-commits mailing list