aboutsummaryrefslogtreecommitdiff
path: root/src/common/token_bucket.c
AgeCommit message (Collapse)Author
2018-04-17Amend token_bucket_rw_dec to indicate which buckets became empty.Nick Mathewson
2018-04-17token bucket: Add parens to rate_per_sec_to_rate_per_step()Nick Mathewson
Typecasts bind more tightly than division, so we need to do the division first.
2018-04-16token: Fix uint32_t to uint64_t conversionDavid Goulet
Unfortunately, the units passed to monotime_coarse_stamp_units_to_approx_msec() was always 0 due to a type conversion. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-04-13token_bucket: Fix indentationDavid Goulet
Both header and code file had some indentation issues after mass renaming. No code behavior change. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-04-13Refactor "timestamp" not to be its own type coupled to token buffersNick Mathewson
Really, the uint32_t is only an optimization; any kind of unit should work fine. Some users might want to use time_t or monotime_coarse_t or something like that.
2018-04-13Move token_bucket_raw_* functions to the start of the module.Nick Mathewson
(These functions were previously helper functions for token_bucket_rw_t).
2018-04-13Never pick a rate of 0.Nick Mathewson
(The tests caught this one.)
2018-04-13Start re-refactoring the token bucket interface.Nick Mathewson
Begin by creating a lowest-level triple of the types needed to implement a token bucket: a configuration, a timestamp, and the raw bucket itself. Note that for low-level buckets, the units of the timestamp and the bucket itself are unspecified: each user can use a different type. (This patch breaks check-spaces; a later patch will fix it)
2018-04-13Rename token_bucket_t to token_bucket_rw_t.Nick Mathewson
This is a simple search-and-replace to rename the token bucket type to indicate that it contains both a read and a write bucket, bundled with their configuration. It's preliminary to refactoring the bucket type.
2018-04-13Accept small hops backward in the monotonic timer.Nick Mathewson
2018-04-13Add a helper function to decrement read and write at the same timeNick Mathewson
2018-04-13Add a new token-bucket backend abstraction, with testsNick Mathewson
This differs from our previous token bucket abstraction in a few ways: 1) It is an abstraction, and not a collection of fields. 2) It is meant to be used with monotonic timestamps, which should produce better results than calling gettimeofday over and over.