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

p2p/discover: fix deadlock in discv5 message dispatch #21858

Merged
merged 2 commits into from
Nov 25, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions p2p/discover/v5_udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,20 @@ func (t *UDPv5) call(node *enode.Node, responseType byte, packet v5wire.Packet)

// callDone tells dispatch that the active call is done.
func (t *UDPv5) callDone(c *callV5) {
select {
case t.callDoneCh <- c:
case <-t.closeCtx.Done():
// In a rare instance, where we still receive response packets
// in the event of a finished call.( after response timeout) We
// continue alleviating and reading the packets from the channel
// in order to prevent any deadlocks in dispatch.
for {
select {
case <-c.ch:
// do nothing and continue waiting for the
// other channels to be ready.
case t.callDoneCh <- c:
return
case <-t.closeCtx.Done():
return
}
}
}

Expand Down