aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Common/TokenBucket.cs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/slskd/Common/TokenBucket.cs b/src/slskd/Common/TokenBucket.cs
index 51a0281b..bce2e913 100644
--- a/src/slskd/Common/TokenBucket.cs
+++ b/src/slskd/Common/TokenBucket.cs
@@ -100,7 +100,12 @@ namespace slskd
CurrentCount = Capacity;
Clock = new System.Timers.Timer(interval);
- Clock.Elapsed += (sender, e) => Reset();
+ Clock.Elapsed += (sender, e) =>
+ {
+ CurrentCount = Capacity;
+ Reset();
+ };
+
Clock.Start();
}
@@ -175,6 +180,7 @@ namespace slskd
}
Capacity = capacity;
+ CurrentCount = Math.Min(CurrentCount, Capacity);
}
/// <summary>
@@ -207,7 +213,6 @@ namespace slskd
if (CurrentCount == 0)
{
await waitForReset.Task.ConfigureAwait(false);
- CurrentCount = Capacity;
}
// take the minimum of requested count or CurrentCount, deduct it from