diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-04-19 15:39:04 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-04-19 15:39:04 -0400 |
commit | 7c83d4043d7f336c14a53418ce91b12335626f6b (patch) | |
tree | e8d6c272e80ad0c9295b5b66cd4320b630b23dbe /src | |
parent | 4a7f979b54c1400190e037b818a241b92e40aabd (diff) | |
parent | 3f7f96d9e7aa2254d62d63530c37ee96d4b3abc8 (diff) | |
download | tor-7c83d4043d7f336c14a53418ce91b12335626f6b.tar.gz tor-7c83d4043d7f336c14a53418ce91b12335626f6b.zip |
Merge remote-tracking branch 'origin/maint-0.2.2'
Diffstat (limited to 'src')
-rw-r--r-- | src/or/rephist.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c index d6b4a03a64..379af092bf 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -1678,7 +1678,7 @@ rep_hist_load_bwhist_state_section(bw_array_t *b, mv *= NUM_SECS_ROLLING_MEASURE; } else { /* No maxima known; guess average rate to be conservative. */ - mv = v / s_interval; + mv = (v / s_interval) * NUM_SECS_ROLLING_MEASURE; } if (!ok) { retval = -1; @@ -1691,11 +1691,24 @@ rep_hist_load_bwhist_state_section(bw_array_t *b, } if (start < now) { - add_obs(b, start, v); + time_t cur_start = start; + time_t actual_interval_len = s_interval; + uint64_t cur_val = 0; + /* Calculate the average per second. This is the best we can do + * because our state file doesn't have per-second resolution. */ + if (start + s_interval > now) + actual_interval_len = now - start; + cur_val = v / actual_interval_len; + /* This is potentially inefficient, but since we don't do it very + * often it should be ok. */ + while (cur_start < start + actual_interval_len) { + add_obs(b, cur_start, cur_val); + ++cur_start; + } b->max_total = mv; /* This will result in some fairly choppy history if s_interval - * is notthe same as NUM_SECS_BW_SUM_INTERVAL. XXXX */ - start += s_interval; + * is not the same as NUM_SECS_BW_SUM_INTERVAL. XXXX */ + start += actual_interval_len; } } SMARTLIST_FOREACH_END(cp); } |