From 2aebeb60618f8944411baad3f91480abf1096888 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 12 Feb 2021 21:15:23 +0000 Subject: [PATCH] accounting: fix --bwlimit when up or down is off - fixes #5019 Before this change the core bandwidth limit was limited to upload or download value if the other value was off. This fix only applies a core bandwidth limit when both values are set. --- fs/accounting/token_bucket.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/accounting/token_bucket.go b/fs/accounting/token_bucket.go index 377d9af44..cafd55e14 100644 --- a/fs/accounting/token_bucket.go +++ b/fs/accounting/token_bucket.go @@ -68,7 +68,8 @@ func newTokenBucket(bandwidth fs.BwPair) (tbs buckets) { bandwidthAccounting = bandwidth.Rx } } - if bandwidthAccounting > 0 { + // Limit core bandwidth to max of Rx and Tx if both are limited + if bandwidth.Tx > 0 && bandwidth.Rx > 0 { tbs[TokenBucketSlotAccounting] = rate.NewLimiter(rate.Limit(bandwidthAccounting), maxBurstSize) } for _, tb := range tbs {