From 6fde2b46d2cc2345ec955b1ed9674a777e5e8716 Mon Sep 17 00:00:00 2001 From: Sebastian Hahn Date: Tue, 26 Apr 2011 15:33:08 +0200 Subject: Fix more of bug 2704 The last entry of the *Maxima values in the state file was inflated by a factor of NUM_SECS_ROLLING_MEASURE (currently 10). This could lead to a wrong maximum value propagating through the state file history. --- src/or/rephist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/or') diff --git a/src/or/rephist.c b/src/or/rephist.c index fb091d5adf..9146fce7f3 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -1614,7 +1614,8 @@ rep_hist_update_bwhist_state_section(or_state_t *state, } tor_asprintf(&cp, U64_FORMAT, U64_PRINTF_ARG(b->total_in_period & ~0x3ff)); smartlist_add(*s_values, cp); - tor_asprintf(&cp, U64_FORMAT, U64_PRINTF_ARG(b->max_total & ~0x3ff)); + maxval = b->max_total / NUM_SECS_ROLLING_MEASURE; + tor_asprintf(&cp, U64_FORMAT, U64_PRINTF_ARG(maxval & ~0x3ff)); smartlist_add(*s_maxima, cp); } -- cgit v1.2.3-54-g00ecf From 1cff525973c9e3934a4e1661b721b8a13d20ff72 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 26 Apr 2011 11:14:46 -0400 Subject: Fix compilation in last patch --- src/or/rephist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/or') diff --git a/src/or/rephist.c b/src/or/rephist.c index 9146fce7f3..524cd1dab4 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -1570,6 +1570,7 @@ rep_hist_update_bwhist_state_section(or_state_t *state, { char *cp; int i,j; + uint64_t maxval; if (*s_values) { SMARTLIST_FOREACH(*s_values, char *, val, tor_free(val)); @@ -1603,7 +1604,6 @@ rep_hist_update_bwhist_state_section(or_state_t *state, /* Set i to first position in circular array */ i = (b->num_maxes_set <= b->next_max_idx) ? 0 : b->next_max_idx; for (j=0; j < b->num_maxes_set; ++j,++i) { - uint64_t maxval; if (i >= NUM_TOTALS) i = 0; tor_asprintf(&cp, U64_FORMAT, U64_PRINTF_ARG(b->totals[i] & ~0x3ff)); -- cgit v1.2.3-54-g00ecf