mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
p2p: wait for goroutine exit, fixes #20558
This commit is contained in:
parent
feda78e052
commit
5ba0dd8880
1 changed files with 6 additions and 1 deletions
|
|
@ -864,7 +864,6 @@ func (srv *Server) maxDialedConns() int {
|
||||||
// listenLoop runs in its own goroutine and accepts
|
// listenLoop runs in its own goroutine and accepts
|
||||||
// inbound connections.
|
// inbound connections.
|
||||||
func (srv *Server) listenLoop() {
|
func (srv *Server) listenLoop() {
|
||||||
defer srv.loopWG.Done()
|
|
||||||
srv.log.Debug("TCP listener up", "addr", srv.listener.Addr())
|
srv.log.Debug("TCP listener up", "addr", srv.listener.Addr())
|
||||||
|
|
||||||
tokens := defaultMaxPendingPeers
|
tokens := defaultMaxPendingPeers
|
||||||
|
|
@ -872,6 +871,12 @@ func (srv *Server) listenLoop() {
|
||||||
tokens = srv.MaxPendingPeers
|
tokens = srv.MaxPendingPeers
|
||||||
}
|
}
|
||||||
slots := make(chan struct{}, tokens)
|
slots := make(chan struct{}, tokens)
|
||||||
|
defer func() {
|
||||||
|
// Wait for a slot. This is to wait for any goroutine(s) doing srv.SetupConn
|
||||||
|
// to complete before exiting
|
||||||
|
<-slots
|
||||||
|
srv.loopWG.Done()
|
||||||
|
}()
|
||||||
for i := 0; i < tokens; i++ {
|
for i := 0; i < tokens; i++ {
|
||||||
slots <- struct{}{}
|
slots <- struct{}{}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue