Compare commits

...

4 Commits

Author SHA1 Message Date
William Banfield
7ec9c8e110 wait in lock 2021-10-04 17:54:34 -04:00
William Banfield
00e8c0e09a fix panic 2021-10-04 17:30:13 -04:00
William Banfield
7696feb552 language 2021-10-04 17:17:58 -04:00
William Banfield
2794e40071 consensus: wait until peerUpdates channel is closed to close remaining peers 2021-10-04 17:16:42 -04:00

View File

@@ -230,17 +230,15 @@ func (r *Reactor) OnStop() {
}
r.mtx.Lock()
peers := r.peers
// Close and wait for each of the peers to shutdown.
// This is safe to perform with the lock since none of the peers require the
// lock to complete any of the methods that the waitgroup is waiting on.
for _, state := range r.peers {
state.closer.Close()
state.broadcastWG.Wait()
}
r.mtx.Unlock()
// wait for all spawned peer goroutines to gracefully exit
for _, ps := range peers {
ps.closer.Close()
}
for _, ps := range peers {
ps.broadcastWG.Wait()
}
// Close the StateChannel goroutine separately since it uses its own channel
// to signal closure.
close(r.stateCloseCh)