aboutsummaryrefslogtreecommitdiff
path: root/src/or/dirserv.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-07-31 16:33:45 -0400
committerNick Mathewson <nickm@torproject.org>2010-07-31 16:33:45 -0400
commitfac272da31554a8ce1095973ac7a08b3028f799f (patch)
treef9e53002ac317ad539f403b038618fc6ffe4d050 /src/or/dirserv.c
parent15424bf800a56007d802db3a9d3fe40fbdf2bee5 (diff)
downloadtor-fac272da31554a8ce1095973ac7a08b3028f799f.tar
tor-fac272da31554a8ce1095973ac7a08b3028f799f.tar.gz
If a router is hibernating, never vote that it is Running.
Also, clean up and comment some of the logic in dirserv_set_router_is_running.
Diffstat (limited to 'src/or/dirserv.c')
-rw-r--r--src/or/dirserv.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 86cd18611..7b469ce54 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. */