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

[R4R] fix: graceful shutdown bug #509

Merged
merged 2 commits into from
Nov 8, 2021
Merged
Changes from all commits
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
12 changes: 12 additions & 0 deletions eth/handler_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ func (h *diffHandler) Chain() *core.BlockChain { return h.chain }
// RunPeer is invoked when a peer joins on the `diff` protocol.
func (h *diffHandler) RunPeer(peer *diff.Peer, hand diff.Handler) error {
if err := peer.Handshake(h.diffSync); err != nil {
// ensure that waitDiffExtension receives the exit signal normally
Copy link
Contributor

Choose a reason for hiding this comment

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

need to add lock for peers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

// otherwise, can't graceful shutdown
ps := h.peers
id := peer.ID()

// Ensure nobody can double connect
ps.lock.Lock()
if wait, ok := ps.diffWait[id]; ok {
delete(ps.diffWait, id)
wait <- peer
}
ps.lock.Unlock()
return err
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the error that you observe?

}
defer h.chain.RemoveDiffPeer(peer.ID())
Expand Down