aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-10-26 19:36:38 -0500
committerJP Dillingham <jp@dillingham.me>2026-10-26 19:36:38 -0500
commitd1c2e879d159f0e20a218a58348be436116134e9 (patch)
tree9d1f793a0964f564ab51771f3be82e05deb6d12e /src
parent6f05ff65e10b8eac8d676d3c69ff1bed1a5b69cd (diff)
downloadslskd-d1c2e879d159f0e20a218a58348be436116134e9.tar.gz
avoid a race in rate limiter
Diffstat (limited to 'src')
-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
{