diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-07-20 23:25:00 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-07-20 23:25:00 +0000 |
commit | 18d752e518c41f7190b77dc36d22150e89ffc115 (patch) | |
tree | 18f063e3ad0f7dec7a932690ba0a4965a1a9f76e /src/or/rephist.c | |
parent | 06c11a61ce3eb3143d99c071d0e05b7fd1bdad45 (diff) | |
download | tor-18d752e518c41f7190b77dc36d22150e89ffc115.tar tor-18d752e518c41f7190b77dc36d22150e89ffc115.tar.gz |
Correct "advance-time" logic
svn:r2069
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r-- | src/or/rephist.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c index b62359e16..5992a9581 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 (when<b->cur_obs_time) + /* Don't record data in the past. */ + if (when<b->cur_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; } |