From b38cb680321d3444abe89ae0306026e1d1d4aa5c Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 13 Oct 2025 18:54:57 -0500 Subject: limit concurrent enqueue requests to 20 --- src/slskd/Application.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 98226d4f..c1e09d42 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -219,6 +219,7 @@ namespace slskd private OptionsAtStartup OptionsAtStartup { get; set; } private IOptionsMonitor OptionsMonitor { get; set; } private SemaphoreSlim OptionsSyncRoot { get; } = new SemaphoreSlim(1, 1); + private SemaphoreSlim EnqueueRequestRateLimiter { get; } = new SemaphoreSlim(20, 20); private Options PreviousOptions { get; set; } private IPushbulletService Pushbullet { get; } private DateTime SharesRefreshStarted { get; set; } @@ -538,6 +539,8 @@ namespace slskd var stopwatch = new Stopwatch(); var decisionStopwatch = new Stopwatch(); + await EnqueueRequestRateLimiter.WaitAsync(); + try { stopwatch.Start(); @@ -748,6 +751,9 @@ namespace slskd { decisionStopwatch.Stop(); stopwatch.Stop(); + + EnqueueRequestRateLimiter.Release(); + Log.Debug("EnqueueDownload for {Username}/{Filename} completed in {ElapsedOverall}ms, decision made in {ElapsedDecision}ms", username, filename, stopwatch.ElapsedMilliseconds, decisionStopwatch.ElapsedMilliseconds); } } -- cgit v1.2.3