diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-04-23 09:47:05 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-04-23 09:47:05 -0400 |
commit | 3527f4b8a4f002e7b910eacd4ead6e9044cb4003 (patch) | |
tree | 11661e8c3b97c649d80001d76fdd60d6a7ad58bc /src/common | |
parent | 1b40e9986bba3667b8dd22af22c2e2f495c1eb6b (diff) | |
parent | bd3f8260a342b9eefc6fc164dc945605cf1ab0d1 (diff) | |
download | tor-3527f4b8a4f002e7b910eacd4ead6e9044cb4003.tar.gz tor-3527f4b8a4f002e7b910eacd4ead6e9044cb4003.zip |
Merge remote-tracking branch 'github/lazy_bucket_refill'
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/token_bucket.c | 13 | ||||
-rw-r--r-- | src/common/token_bucket.h | 4 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/common/token_bucket.c b/src/common/token_bucket.c index 747189e751..f2396ec58a 100644 --- a/src/common/token_bucket.c +++ b/src/common/token_bucket.c @@ -238,13 +238,18 @@ token_bucket_rw_dec_write(token_bucket_rw_t *bucket, /** * As token_bucket_rw_dec_read and token_bucket_rw_dec_write, in a single - * operation. + * operation. Return a bitmask of TB_READ and TB_WRITE to indicate + * which buckets became empty. */ -void +int token_bucket_rw_dec(token_bucket_rw_t *bucket, ssize_t n_read, ssize_t n_written) { - token_bucket_rw_dec_read(bucket, n_read); - token_bucket_rw_dec_write(bucket, n_written); + int flags = 0; + if (token_bucket_rw_dec_read(bucket, n_read)) + flags |= TB_READ; + if (token_bucket_rw_dec_write(bucket, n_written)) + flags |= TB_WRITE; + return flags; } diff --git a/src/common/token_bucket.h b/src/common/token_bucket.h index fb5d9fc60a..0e7832e838 100644 --- a/src/common/token_bucket.h +++ b/src/common/token_bucket.h @@ -85,8 +85,8 @@ int token_bucket_rw_dec_read(token_bucket_rw_t *bucket, int token_bucket_rw_dec_write(token_bucket_rw_t *bucket, ssize_t n); -void token_bucket_rw_dec(token_bucket_rw_t *bucket, - ssize_t n_read, ssize_t n_written); +int token_bucket_rw_dec(token_bucket_rw_t *bucket, + ssize_t n_read, ssize_t n_written); static inline size_t token_bucket_rw_get_read(const token_bucket_rw_t *bucket); static inline size_t |