Ticket #5235: 0001-rate-limit-weighted-bandwidth-is-zero-message-alternate.patch

File 0001-rate-limit-weighted-bandwidth-is-zero-message-alternate.patch, 2.2 KB (added by andrea, 8 years ago)

Alternate patch which also modifies message to emit unweighted bandwidth, to distinguish between possible causes

  • src/or/routerlist.c

    From 2e0b6913f4e1577f0da299789d71dff7f8fb9d2a Mon Sep 17 00:00:00 2001
    From: Andrea Shepard <andrea@persephoneslair.org>
    Date: Fri, 8 Jun 2012 03:00:30 -0700
    Subject: [PATCH] Rate-limit 'Weighted bandwidth is 0.000000 ...' message; it can be produced in extreme quantities
    
    ---
     src/or/routerlist.c |   21 ++++++++++++++++-----
     1 files changed, 16 insertions(+), 5 deletions(-)
    
    diff --git a/src/or/routerlist.c b/src/or/routerlist.c
    index c3e6f48..3be029b 100644
    a b smartlist_choose_node_by_bandwidth_weights(smartlist_t *sl, 
    16991699  int64_t rand_bw;
    17001700  double Wg = -1, Wm = -1, We = -1, Wd = -1;
    17011701  double Wgb = -1, Wmb = -1, Web = -1, Wdb = -1;
    1702   double weighted_bw = 0;
     1702  double weighted_bw = 0, unweighted_bw = 0;
    17031703  double *bandwidths;
    17041704  double tmp = 0;
    17051705  unsigned int i;
    smartlist_choose_node_by_bandwidth_weights(smartlist_t *sl, 
    18261826
    18271827    bandwidths[node_sl_idx] = weight*this_bw;
    18281828    weighted_bw += weight*this_bw;
     1829    unweighted_bw += this_bw;
    18291830    if (is_me)
    18301831      sl_last_weighted_bw_of_me = weight*this_bw;
    18311832  } SMARTLIST_FOREACH_END(node);
    smartlist_choose_node_by_bandwidth_weights(smartlist_t *sl, 
    18411842  /* If there is no bandwidth, choose at random */
    18421843  if (DBL_TO_U64(weighted_bw) == 0) {
    18431844    /* Don't warn when using bridges/relays not in the consensus */
    1844     if (!have_unknown)
    1845       log_warn(LD_CIRC,
    1846                "Weighted bandwidth is %f in node selection for rule %s",
    1847                weighted_bw, bandwidth_weight_rule_to_string(rule));
     1845    if (!have_unknown) {
     1846#define ZERO_BANDWIDTH_WARNING_INTERVAL (15)
     1847      static ratelim_t zero_bandwidth_warning_limit =
     1848        RATELIM_INIT(ZERO_BANDWIDTH_WARNING_INTERVAL);
     1849      char *msg;
     1850      if ( ( msg = rate_limit_log( &zero_bandwidth_warning_limit,
     1851                                 approx_time() ) ) ) {
     1852        log_warn(LD_CIRC,
     1853                 "Weighted bandwidth is %f in node selection for rule %s "
     1854                 "(unweighted was %f) %s",
     1855                 weighted_bw, bandwidth_weight_rule_to_string(rule),
     1856                 unweighted_bw, msg);
     1857      }
     1858    }
    18481859    tor_free(bandwidths);
    18491860    return smartlist_choose(sl);
    18501861  }