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: ensure Server.loop is ticking even if discovery hangs #20573

Merged
merged 1 commit into from
Jan 17, 2020
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
6 changes: 6 additions & 0 deletions p2p/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,12 @@ func (srv *Server) run(dialstate dialer) {
inboundCount = 0
trusted = make(map[enode.ID]bool, len(srv.TrustedNodes))
taskdone = make(chan task, maxActiveDialTasks)
tick = time.NewTicker(30 * time.Second)
runningTasks []task
queuedTasks []task // tasks that can't run yet
)
defer tick.Stop()

// Put trusted nodes into a map to speed up checks.
// Trusted peers are loaded on startup or added via AddTrustedPeer RPC.
for _, n := range srv.TrustedNodes {
Expand Down Expand Up @@ -694,6 +697,9 @@ running:
scheduleTasks()

select {
case <-tick.C:
// This is just here to ensure the dial scheduler runs occasionally.

case <-srv.quit:
// The server was stopped. Run the cleanup logic.
break running
Expand Down