[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/release-0.2.2] Fix bug when parsing bwhist with unexpected Interval



commit 7e1502c0d1aa0875fba0b26ddcf021bdfa5e11a0
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Mon Jan 10 13:06:50 2011 -0500

    Fix bug when parsing bwhist with unexpected Interval
    
    Previously, our state parsing code would fail to parse a bwhist
    correctly if the Interval was anything other than the default
    hardcoded 15 minutes.  This change makes the parsing less incorrect,
    though the resulting history array might get strange values in it if
    the intervals don't match the one we're using.  (That is, if stuff was
    generated in 15 minute intervals, and we read it into an array that
    expects 30 minute intervals, we're fine, since values can be combined
    pairwise.  But if we generate data at 30 minute intervals and read it
    into 15 minute intervals, alternating buckets will be empty.)
    
    Bugfix on 0.1.1.11-alpha.
---
 changes/1863_bwhist |    5 +++++
 src/or/rephist.c    |    6 +++++-
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/changes/1863_bwhist b/changes/1863_bwhist
new file mode 100644
index 0000000..c1d4d86
--- /dev/null
+++ b/changes/1863_bwhist
@@ -0,0 +1,5 @@
+  o Minor bugfixes
+    - Fix a bug in banwidth history state parsing that could have been
+      triggered if a future version of Tor ever changed the timing
+      granularity at which bandwidth history is measured.  Bugfix on
+      Tor 0.1.1.11-alpha.
diff --git a/src/or/rephist.c b/src/or/rephist.c
index c220426..5a3a15e 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -1165,6 +1165,8 @@ rep_hist_load_mtbf_data(time_t now)
  * totals? */
 #define NUM_SECS_ROLLING_MEASURE 10
 /** How large are the intervals for which we track and report bandwidth use? */
+/* XXXX Watch out! Before Tor 0.2.2.21-alpha, using any other value here would
+ * generate an unparseable state file. */
 #define NUM_SECS_BW_SUM_INTERVAL (15*60)
 /** How far in the past do we remember and publish bandwidth use? */
 #define NUM_SECS_BW_SUM_IS_VALID (24*60*60)
@@ -1577,7 +1579,9 @@ rep_hist_load_bwhist_state_section(bw_array_t *b,
         }
         if (start < now) {
           add_obs(b, start, v);
-          start += NUM_SECS_BW_SUM_INTERVAL;
+          /* This will result in some fairly choppy history if s_interval
+           * is notthe same as NUM_SECS_BW_SUM_INTERVAL. XXXX */
+          start += s_interval;
         }
     } SMARTLIST_FOREACH_END(cp);
   }



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits