diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-09-07 22:00:48 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-09-22 15:07:34 -0400 |
commit | 41dfc4c19c4e0ee37d092fa0ed7faf349e6ab467 (patch) | |
tree | 621914608ae5e2031a044448ee3c07d68144dbb6 /src/or/connection_or.c | |
parent | 052b95e2f196211c97b33ce8c68960e1c2561ea0 (diff) | |
download | tor-41dfc4c19c4e0ee37d092fa0ed7faf349e6ab467.tar.gz tor-41dfc4c19c4e0ee37d092fa0ed7faf349e6ab467.zip |
Make bufferevents work with TokenBucketRefillInterval
Diffstat (limited to 'src/or/connection_or.c')
-rw-r--r-- | src/or/connection_or.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c index a75444e1ed..29f0f8de72 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -580,7 +580,12 @@ connection_or_update_token_buckets_helper(or_connection_t *conn, int reset, { const struct timeval *tick = tor_libevent_get_one_tick_timeout(); struct ev_token_bucket_cfg *cfg, *old_cfg; - int rate_per_tick = rate / TOR_LIBEVENT_TICKS_PER_SECOND; + int64_t rate64 = (((int64_t)rate) * options->TokenBucketRefillInterval) + / 1000; + /* This can't overflow, since TokenBucketRefillInterval <= 1000, + * and rate started out less than INT_MAX. */ + int rate_per_tick = (int) rate64; + cfg = ev_token_bucket_cfg_new(rate_per_tick, burst, rate_per_tick, burst, tick); old_cfg = conn->bucket_cfg; |