diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-11-08 10:15:14 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-08 10:15:14 -0600 |
| commit | 169bb8a3c0098599a617d8553e93c694bd813795 (patch) | |
| tree | 4d825302717fc76d543b6a24469ad23a605cd5c8 /src/slskd/Search/SearchService.cs | |
| parent | 4eaa2b13e2da250d7b89073a15e9f1e077661fd7 (diff) | |
| parent | cefdcd02e28b1f02f546002fdd475de4fa03e839 (diff) | |
| download | slskd-169bb8a3c0098599a617d8553e93c694bd813795.tar.gz | |
Merge branch 'master' into dependabot/npm_and_yarn/src/web/follow-redirects-1.16.2
Diffstat (limited to 'src/slskd/Search/SearchService.cs')
| -rw-r--r-- | src/slskd/Search/SearchService.cs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/slskd/Search/SearchService.cs b/src/slskd/Search/SearchService.cs index 208e8f9d..8b107084 100644 --- a/src/slskd/Search/SearchService.cs +++ b/src/slskd/Search/SearchService.cs @@ -271,7 +271,8 @@ namespace slskd.Search // initialize the list of responses that we'll use to accumulate them // populated by the responseHandler we pass to SearchAsync - List<SearchResponse> responses = new(); + // responses arrive concurrently from many connections, so this must be thread safe + ConcurrentQueue<SearchResponse> responses = new(); options ??= new SearchOptions(); options = options.WithActions( @@ -308,7 +309,7 @@ namespace slskd.Search // the client state (e.g. disconnected) or a problem with the search (e.g. no terms) var soulseekSearchTask = Client.SearchAsync( query, - responseHandler: (response) => responses.Add(response), + responseHandler: (response) => responses.Enqueue(response), scope, token, options, @@ -377,7 +378,7 @@ namespace slskd.Search rateLimiter.Dispose(); CancellationTokens.TryRemove(id, out _); } - }, cancellationToken: cancellationTokenSource.Token); + }); // broadcast and return the _newly created_ search; it will continue to be updated in the background await SearchHub.BroadcastUpdateAsync(search); |
