diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-10-26 19:36:38 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-10-26 19:36:38 -0500 |
| commit | d1c2e879d159f0e20a218a58348be436116134e9 (patch) | |
| tree | 9d1f793a0964f564ab51771f3be82e05deb6d12e | |
| parent | 6f05ff65e10b8eac8d676d3c69ff1bed1a5b69cd (diff) | |
| download | slskd-d1c2e879d159f0e20a218a58348be436116134e9.tar.gz | |
avoid a race in rate limiter
| -rw-r--r-- | src/slskd/Common/RateLimiter.cs | 6 |
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 { |
