Ticket #1023: 0001-Don-t-set-unreachable-from-dirvote-unless-we-ve-been.patch

File 0001-Don-t-set-unreachable-from-dirvote-unless-we-ve-been.patch, 2.6 KB (added by nickm, 10 years ago)
  • src/or/dirserv.c

    From dbbdf07ab480aed960b4c1fbd20dfa257e512287 Mon Sep 17 00:00:00 2001
    From: Nick Mathewson <nickm@torproject.org>
    Date: Thu, 2 Jul 2009 13:56:52 -0400
    Subject: [PATCH] Don't set unreachable from dirvote unless we've been running a while.
    
    This is a possible fix for bug 1023, where if we vote (or make a v2
    consenus networkstatus) right after we come online, we can call
    rep_hist_note_router_unreachable() on every router we haven't connected
    to yet, and thereby make all their uptime values reset.
    ---
     src/or/dirserv.c |   19 +++++++++++++------
     1 files changed, 13 insertions(+), 6 deletions(-)
    
    diff --git a/src/or/dirserv.c b/src/or/dirserv.c
    index a64a01b..b8a31da 100644
    a b list_single_server_status(routerinfo_t *desc, int is_live) 
    932932  return tor_strdup(buf);
    933933}
    934934
     935static INLINE int
     936running_long_enough_to_decide_unreachable(void)
     937{
     938  return time_of_process_start
     939    + get_options()->TestingAuthDirTimeToLearnReachability < approx_time();
     940}
     941
    935942/** Each server needs to have passed a reachability test no more
    936943 * than this number of seconds ago, or he is listed as down in
    937944 * the directory. */
    list_single_server_status(routerinfo_t *desc, int is_live) 
    943950void
    944951dirserv_set_router_is_running(routerinfo_t *router, time_t now)
    945952{
     953  /*XXXX022 This function is a mess.  Separate out the part that calculates
     954    whether it's reachable and the part that tells rephist that the router was
     955    unreachable.
     956   */
    946957  int answer;
    947958
    948959  if (router_is_me(router) && !we_are_hibernating())
    dirserv_set_router_is_running(routerinfo_t *router, time_t now) 
    951962    answer = get_options()->AssumeReachable ||
    952963             now < router->last_reachable + REACHABLE_TIMEOUT;
    953964
    954   if (!answer) {
     965  if (!answer && running_long_enough_to_decide_unreachable()) {
    955966    /* not considered reachable. tell rephist. */
    956967    rep_hist_note_router_unreachable(router->cache_info.identity_digest, now);
    957968  }
    dirserv_generate_networkstatus_vote_obj(crypto_pk_env_t *private_key, 
    22552266  networkstatus_voter_info_t *voter = NULL;
    22562267  vote_timing_t timing;
    22572268  digestmap_t *omit_as_sybil = NULL;
    2258   int vote_on_reachability = 1;
     2269  const int vote_on_reachability = running_long_enough_to_decide_unreachable();
    22592270
    22602271  tor_assert(private_key);
    22612272  tor_assert(cert);
    22622273
    2263   if (now - time_of_process_start <
    2264       options->TestingAuthDirTimeToLearnReachability)
    2265     vote_on_reachability = 0;
    2266 
    22672274  if (resolve_my_address(LOG_WARN, options, &addr, &hostname)<0) {
    22682275    log_warn(LD_NET, "Couldn't resolve my hostname");
    22692276    return NULL;