summaryrefslogtreecommitdiff
path: root/src/or/rephist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-08-18 18:20:42 +0000
committerNick Mathewson <nickm@torproject.org>2007-08-18 18:20:42 +0000
commit676d8622deb70e5d14b19bb22d0f0856cfaad9b3 (patch)
tree95391b4561e22a1ec9622e53d330653df91b96f5 /src/or/rephist.c
parent648c8261fd8101ef43de57e80a41c67a96ec5330 (diff)
downloadtor-676d8622deb70e5d14b19bb22d0f0856cfaad9b3.tar.gz
tor-676d8622deb70e5d14b19bb22d0f0856cfaad9b3.zip
r14659@catbus: nickm | 2007-08-18 14:19:34 -0400
When we are loading state info from disk, never believe any date in the future. Doing so can keep us from retrying guards, rotating onion keys, storing bandwidth info, etc. Fixes bug 434, and others. Backport candidate, once it has been tested. svn:r11166
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r--src/or/rephist.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 1bb8775d8f..3228d24a3f 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -993,7 +993,8 @@ rep_hist_load_state(or_state_t *state, char **err)
s_values = r?state->BWHistoryReadValues:state->BWHistoryWriteValues;
if (s_values && s_begins >= now - NUM_SECS_BW_SUM_INTERVAL*NUM_TOTALS) {
start = s_begins - s_interval*(smartlist_len(s_values));
-
+ if (start > now)
+ continue;
b->cur_obs_time = start;
b->next_period = start + NUM_SECS_BW_SUM_INTERVAL;
SMARTLIST_FOREACH(s_values, char *, cp, {
@@ -1002,8 +1003,10 @@ rep_hist_load_state(or_state_t *state, char **err)
all_ok=0;
log_notice(LD_GENERAL, "Could not parse '%s' into a number.'", cp);
}
- add_obs(b, start, v);
- start += NUM_SECS_BW_SUM_INTERVAL;
+ if (start < now) {
+ add_obs(b, start, v);
+ start += NUM_SECS_BW_SUM_INTERVAL;
+ }
});
}