-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Conversation
…fExtension can't receive exit signal
@@ -33,6 +33,15 @@ 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
delete(ps.diffWait, id) | ||
wait <- peer | ||
} | ||
ps.lock.Unlock() | ||
return err |
There was a problem hiding this comment.
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?
fix: graceful shutdown bug
Description
delete(ps.diffWait, id)
while the handshake fails onhandler_diff.go
Rationale
The preceding error occurs multiple times when node
stop()
. Wait channel inwaitDiffExtension
can't exit normally.In
runEthPeer
ofeth/handler.go
, if the peer has adiff
extension, wait for it to connect throughpeerset.diffWait
channel.While
RunPeer
ofeth/handler_diff.go
runs, if thepeer.Handshake
is successful,peerset.diffWait[id]
will exit and be removed. If it it not successful,peerset.diffWait[id]
onwaitDiffExtension
will keep waiting. Which causedgraceful shutdown
cannot be enabledExample
add an example CLI or API response...
Changes
Notable changes:
Preflight checks
make build
)make test
)Already reviewed by
...
Related issues
#479