From: Nick Mathewson Date: Tue, 20 Jul 2004 23:25:00 +0000 (+0000) Subject: Correct "advance-time" logic X-Git-Tag: tor-0.0.8pre1~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18d752e518c41f7190b77dc36d22150e89ffc115;p=thirdparty%2Ftor.git Correct "advance-time" logic svn:r2069 --- diff --git a/src/or/rephist.c b/src/or/rephist.c index b62359e162..5992a95810 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -378,10 +378,15 @@ static INLINE void advance_obs(bw_array_t *b) { /** Add 'n' bytes to the number of bytes in b for second 'when'. */ static INLINE void add_obs(bw_array_t *b, time_t when, int n) { - /* If we're currently adding observations for an earlier second than 'when', - * advance 'when' by an appropriate number of seconds. */ - while (whencur_obs_time) + /* Don't record data in the past. */ + if (whencur_obs_time) + return; + /* If we're currently adding observations for an earlier second than + * 'when', advance b->cur_obs_time and b->cur_obs_idx by an + * appropriate number of seconds, and do all the other housekeeping */ + while (when>b->cur_obs_time) advance_obs(b); + b->obs[b->cur_obs_idx] += n; }