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] Ratelimit '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, 
1699  1699  int64_t rand_bw; 
1700  1700  double Wg = 1, Wm = 1, We = 1, Wd = 1; 
1701  1701  double Wgb = 1, Wmb = 1, Web = 1, Wdb = 1; 
1702   double weighted_bw = 0; 
 1702  double weighted_bw = 0, unweighted_bw = 0; 
1703  1703  double *bandwidths; 
1704  1704  double tmp = 0; 
1705  1705  unsigned int i; 
… 
… 
smartlist_choose_node_by_bandwidth_weights(smartlist_t *sl, 
1826  1826  
1827  1827  bandwidths[node_sl_idx] = weight*this_bw; 
1828  1828  weighted_bw += weight*this_bw; 
 1829  unweighted_bw += this_bw; 
1829  1830  if (is_me) 
1830  1831  sl_last_weighted_bw_of_me = weight*this_bw; 
1831  1832  } SMARTLIST_FOREACH_END(node); 
… 
… 
smartlist_choose_node_by_bandwidth_weights(smartlist_t *sl, 
1841  1842  /* If there is no bandwidth, choose at random */ 
1842  1843  if (DBL_TO_U64(weighted_bw) == 0) { 
1843  1844  /* 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  } 
1848  1859  tor_free(bandwidths); 
1849  1860  return smartlist_choose(sl); 
1850  1861  } 