diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-04-10 12:34:28 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-04-13 10:41:14 -0400 |
commit | 9fced56ef1a6eae0ce01de310c871823998bd791 (patch) | |
tree | e361226027bc9275a5d2158a8a08fbfccc3c8b3a /src/or/connection_or.c | |
parent | 8a852397462e39cfbc21e3cea20ddd39be40598d (diff) | |
download | tor-9fced56ef1a6eae0ce01de310c871823998bd791.tar.gz tor-9fced56ef1a6eae0ce01de310c871823998bd791.zip |
Refactor or_connection token buckets to use token_bucket_t
Diffstat (limited to 'src/or/connection_or.c')
-rw-r--r-- | src/or/connection_or.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c index 267463312c..3afdfa6b5a 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -793,18 +793,10 @@ connection_or_update_token_buckets_helper(or_connection_t *conn, int reset, (int)options->BandwidthBurst, 1, INT32_MAX); } - conn->bandwidthrate = rate; - conn->bandwidthburst = burst; - if (reset) { /* set up the token buckets to be full */ - conn->read_bucket = conn->write_bucket = burst; - return; + token_bucket_adjust(&conn->bucket, rate, burst); + if (reset) { + token_bucket_reset(&conn->bucket, monotime_coarse_get_stamp()); } - /* If the new token bucket is smaller, take out the extra tokens. - * (If it's larger, don't -- the buckets can grow to reach the cap.) */ - if (conn->read_bucket > burst) - conn->read_bucket = burst; - if (conn->write_bucket > burst) - conn->write_bucket = burst; } /** Either our set of relays or our per-conn rate limits have changed. |