mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
swarm/network/simulation: adjust disconnections on simulation close
This commit is contained in:
parent
6959c93e3e
commit
5d419c3edb
1 changed files with 8 additions and 8 deletions
|
|
@ -161,6 +161,14 @@ var maxParallelCleanups = 10
|
|||
// simulation.
|
||||
func (s *Simulation) Close() {
|
||||
close(s.done)
|
||||
// Close all connections before calling the Network Shutdown.
|
||||
// It is possible that p2p.Server.Stop will block if there are
|
||||
// existing connections.
|
||||
for _, c := range s.Net.Conns {
|
||||
if c.Up {
|
||||
s.Net.Disconnect(c.One, c.Other)
|
||||
}
|
||||
}
|
||||
sem := make(chan struct{}, maxParallelCleanups)
|
||||
s.mu.RLock()
|
||||
cleanupFuncs := make([]func(), len(s.cleanupFuncs))
|
||||
|
|
@ -190,14 +198,6 @@ func (s *Simulation) Close() {
|
|||
close(s.runC)
|
||||
}
|
||||
s.shutdownWG.Wait()
|
||||
// Close all connections before calling the Network Shutdown.
|
||||
// It is possible that p2p.Server.Stop will block if there are
|
||||
// existing connections.
|
||||
for _, c := range s.Net.Conns {
|
||||
if c.Up {
|
||||
s.Net.Disconnect(c.One, c.Other)
|
||||
}
|
||||
}
|
||||
s.Net.Shutdown()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue