aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Common/RateLimiter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/slskd/Common/RateLimiter.cs')
-rw-r--r--src/slskd/Common/RateLimiter.cs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/slskd/Common/RateLimiter.cs b/src/slskd/Common/RateLimiter.cs
index ac34ed5d..7229441f 100644
--- a/src/slskd/Common/RateLimiter.cs
+++ b/src/slskd/Common/RateLimiter.cs
@@ -97,6 +97,7 @@ namespace slskd
return;
}
+ // previously staged action is lost, intentionally
Staged = action;
}
@@ -131,8 +132,11 @@ namespace slskd
{
try
{
- Staged?.Invoke();
+ // capture the staged action before nulling it to avoid
+ // a race where another action might slip in between the invoke and null
+ var staged = Staged;
Staged = null;
+ staged?.Invoke();
}
finally
{