Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

make closing the query events channel safe #31

Merged
merged 3 commits into from
Oct 23, 2018
Merged

Conversation

Stebalien
Copy link
Member

fixes ipfs/kubo#5616

Basically, we need to be able to close and write to the channel under the same lock. With this change, we can manage the channel with the context itself.

1. Instead of accepting a passed-in channel, create one (and return a read-only
channel).
2. Close the channel when the context is canceled.

Together, these allow us to safely close the event channel.

Technically, this is an API-breaking change but this is (a) an internal API
and (b) unavoidable (I think). That is, I'm pretty sure there's no way to fix
this without changing this method signature somehow (we need to somehow
synchronize closing of this channel with writing to it).

fixes ipfs/kubo#5616

peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
)

const RoutingQueryKey = "RoutingQueryEvent"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go vet issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic when use api dht/provide.
2 participants