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.
This commit is contained in:
Nick Mathewson 2010-07-31 16:33:45 -04:00
parent 15424bf800
commit fac272da31
2 changed files with 18 additions and 3 deletions

View File

@ -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.

View File

@ -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. */