aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Search/SearchService.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-10-25 22:03:15 -0500
committerJP Dillingham <jp@dillingham.me>2026-10-25 22:03:15 -0500
commitc7984d965f4d2d323091d5b87e558ca57a7e1011 (patch)
treedd55898dc264962925ede0d98cac47d031aca871 /src/slskd/Search/SearchService.cs
parent4b3bc19e6411ea16bf2c6bfe50468ca92034b287 (diff)
downloadslskd-c7984d965f4d2d323091d5b87e558ca57a7e1011.tar.gz
use a thread safe collection for responses
Diffstat (limited to 'src/slskd/Search/SearchService.cs')
-rw-r--r--src/slskd/Search/SearchService.cs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/slskd/Search/SearchService.cs b/src/slskd/Search/SearchService.cs
index 4051eeab..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,