Skip to content

fix: use oneshot channel to send search outcome back#190

Merged
ldm0 merged 2 commits intomasterfrom
fix/search_result_channel
Apr 28, 2026
Merged

fix: use oneshot channel to send search outcome back#190
ldm0 merged 2 commits intomasterfrom
fix/search_result_channel

Conversation

@hsqStephenZhang
Copy link
Copy Markdown
Collaborator

Goal

eliminate usage of MPMC channel for search job to make the http api works with UI.

Background

http api and UI both interact with the background loop since it's the background loop that receives the search job and do the actual search.
but current usage of MPMC channel may cause race condition, resulting in non-deterministic behavior.

Solution

add a Sender in SearchJob(this behavior aligns with NodeInfoRequest) so the background loop could send the result back via it.

Tests

https://gist.github.com/hsqStephenZhang/bd14bd8021be3b49c33afb2194a97711 this test case test the race condition via simulating two concurrrent searches.
it failed before the change, but works after this PR, the new test case is here).

@hsqStephenZhang hsqStephenZhang requested a review from ldm0 April 28, 2026 08:35
Comment thread doc/inner/background-event-loop.md Outdated
@ldm0 ldm0 merged commit 89ebb1a into master Apr 28, 2026
10 checks passed
@ldm0 ldm0 deleted the fix/search_result_channel branch April 28, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants