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: resolved deadlock on p2p server shutdown #2183

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,6 @@ func (h *handler) protoTracker() {
<-h.handlerDoneCh
}
return
case <-h.stopCh:
return
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions eth/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ func (cs *chainSyncer) loop() {
<-cs.doneCh
}
return
case <-cs.handler.stopCh:
return
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions p2p/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ const (

// Maximum amount of time allowed for writing a complete message.
frameWriteTimeout = 20 * time.Second

// Maximum time to wait before stop the p2p server
stopTimeout = 5 * time.Second
)

var (
Expand Down Expand Up @@ -457,7 +454,7 @@ func (srv *Server) Stop() {

select {
case <-stopChan:
case <-time.After(stopTimeout):
case <-time.After(defaultDialTimeout): // we should use defaultDialTimeout as we can dial just before the shutdown
srv.log.Warn("stop p2p server timeout, forcing stop")
}
}
Expand Down
4 changes: 2 additions & 2 deletions p2p/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ func TestServerStopTimeout(t *testing.T) {

select {
case <-stopChan:
case <-time.After(10 * time.Second):
t.Error("server should be shutdown in 10 seconds")
case <-time.After(defaultDialTimeout + 1*time.Second):
t.Error("server should be shutdown in defaultDialTimeout + 1 seconds")
}
}

Expand Down
Loading