Amend token_bucket_rw_dec to indicate which buckets became empty.

This commit is contained in:
Nick Mathewson 2018-04-17 12:02:49 -04:00
parent 1356d51af6
commit b36c450b57
2 changed files with 11 additions and 6 deletions

View File

@ -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 * 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, token_bucket_rw_dec(token_bucket_rw_t *bucket,
ssize_t n_read, ssize_t n_written) ssize_t n_read, ssize_t n_written)
{ {
token_bucket_rw_dec_read(bucket, n_read); int flags = 0;
token_bucket_rw_dec_write(bucket, n_written); 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;
} }

View File

@ -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, int token_bucket_rw_dec_write(token_bucket_rw_t *bucket,
ssize_t n); ssize_t n);
void token_bucket_rw_dec(token_bucket_rw_t *bucket, int token_bucket_rw_dec(token_bucket_rw_t *bucket,
ssize_t n_read, ssize_t n_written); 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 token_bucket_rw_get_read(const token_bucket_rw_t *bucket);
static inline size_t static inline size_t