peer+server: ensure the remote TCP connection is always closed

This commit is contained in:
Olaoluwa Osuntokun
2017-02-06 15:04:52 -08:00
parent 38d8d37395
commit 8c059631df
2 changed files with 14 additions and 12 deletions

View File

@@ -518,9 +518,14 @@ func (s *server) removePeer(p *peer) {
return
}
// As the peer is now finished, ensure that the TCP connection is
// closed and all of its related goroutines have exited.
if err := p.Stop(); err != nil {
peerLog.Errorf("unable to stop peer: %v", err)
}
// Ignore deleting peers if we're shutting down.
if atomic.LoadInt32(&s.shutdown) != 0 {
p.Stop()
return
}