Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: context cancel causes providers not to be returned in findProvidersAsync #799

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

noot
Copy link
Contributor

@noot noot commented Nov 30, 2022

I found an issue when testing the double-hashed prefix-lookup DHT; I noticed providers were being returned in the queryFn in findProvidersAsync, but they weren't being entered into the peerOut channel because the context was cancelled, resulting in no providers being returned.

Previously, context being passed to the queryFn gets cancelled when the query terminates in query.Run; however since the queryFn is run in a goroutine (query.go line 325) it's possible for the context passed to it to be cancelled before providers are put into the peerOut channel, resulting in no/less providers than expected being returned.

It seems to me like the query.ctx (which is passed by the user essentially) should be what stops values being put in the peerOut channel, which is what the PR now does (and also fixes the above issue).

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.

1 participant