[or-cvs] [tor/master 1/9] If a router is hibernating, never vote that it is Running.

nickm at torproject.org nickm at torproject.org
Wed Sep 15 02:17:38 UTC 2010


Author: Nick Mathewson <nickm at torproject.org>
Date: Sat, 31 Jul 2010 16:33:45 -0400
Subject: If a router is hibernating, never vote that it is Running.
Commit: fac272da31554a8ce1095973ac7a08b3028f799f

Also, clean up and comment some of the logic in
dirserv_set_router_is_running.
---
 changes/bug911_hibernate_precludes_Running |    5 +++++
 src/or/dirserv.c                           |   16 +++++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)
 create mode 100644 changes/bug911_hibernate_precludes_Running

diff --git a/changes/bug911_hibernate_precludes_Running b/changes/bug911_hibernate_precludes_Running
new file mode 100644
index 0000000..e8f2792
--- /dev/null
+++ b/changes/bug911_hibernate_precludes_Running
@@ -0,0 +1,5 @@
+  o Minor bugfixes:
+    - Never vote for a server as "Running" if we have a descriptor for it
+      claiming to be hibernating, and that descriptor was published more
+      recently than our last contact with the server.
+
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 86cd186..7b469ce 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -935,11 +935,21 @@ dirserv_set_router_is_running(routerinfo_t *router, time_t now)
    */
   int answer;
 
-  if (router_is_me(router) && !we_are_hibernating())
+  if (router_is_me(router))
+    /* We always know if we are down ourselves. */
+    answer = ! we_are_hibernating();
+  else if (router->is_hibernating &&
+           router->cache_info.published_on > router->last_reachable)
+    /* A hibernating router is down unless we (somehow) had contact with it
+     * since it declared itself to be hibernating. */
+    answer = 0;
+  else if (get_options()->AssumeReachable)
+    /* If AssumeReachable, everybody is up! */
     answer = 1;
   else
-    answer = get_options()->AssumeReachable ||
-             now < router->last_reachable + REACHABLE_TIMEOUT;
+    /* Otherwise, a router counts as up if we found it reachable in the last
+       REACHABLE_TIMEOUT seconds. */
+    answer = (now < router->last_reachable + REACHABLE_TIMEOUT);
 
   if (!answer && running_long_enough_to_decide_unreachable()) {
     /* not considered reachable. tell rephist. */
-- 
1.7.1




More information about the tor-commits mailing list