aboutsummaryrefslogtreecommitdiff
path: root/src/or/router.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-09-23 08:34:22 -0400
committerNick Mathewson <nickm@torproject.org>2014-09-29 09:05:11 -0400
commit8527a2996675d9502551ccdd4224036a45aae47b (patch)
tree9b2ab6a02949da52b42b5b1b1b4cd7a29465e778 /src/or/router.c
parente6150c7fc079d7841bedd0df838b29aef0f497d7 (diff)
downloadtor-8527a2996675d9502551ccdd4224036a45aae47b.tar.gz
tor-8527a2996675d9502551ccdd4224036a45aae47b.zip
Add an "AccountingRule" feature to permit limiting bw usage by read+write
Patch from "chobe". Closes ticket 961.
Diffstat (limited to 'src/or/router.c')
-rw-r--r--src/or/router.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/or/router.c b/src/or/router.c
index 4af8d262f9..96d16bb326 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -1080,6 +1080,7 @@ decide_to_advertise_dirport(const or_options_t *options, uint16_t dir_port)
* they're confused or to get statistics. */
int interval_length = accounting_get_interval_length();
uint32_t effective_bw = get_effective_bwrate(options);
+ uint64_t acc_bytes;
if (!interval_length) {
log_warn(LD_BUG, "An accounting interval is not allowed to be zero "
"seconds long. Raising to 1.");
@@ -1090,8 +1091,12 @@ decide_to_advertise_dirport(const or_options_t *options, uint16_t dir_port)
"accounting interval length %d", effective_bw,
U64_PRINTF_ARG(options->AccountingMax),
interval_length);
+
+ acc_bytes = options->AccountingMax;
+ if (strcmp(options->AccountingRule, "sum") == 0)
+ acc_bytes /= 2;
if (effective_bw >=
- options->AccountingMax / interval_length) {
+ acc_bytes / interval_length) {
new_choice = 0;
reason = "AccountingMax enabled";
}