[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Amend token_bucket_rw_dec to indicate which buckets became empty.
commit b36c450b572b561c615f0c6501664be17290318a
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Tue Apr 17 12:02:49 2018 -0400
Amend token_bucket_rw_dec to indicate which buckets became empty.
---
src/common/token_bucket.c | 13 +++++++++----
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 747189e75..f2396ec58 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 fb5d9fc60..0e7832e83 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
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits