actually stop peer on failed Add

This commit is contained in:
Ethan Buchman
2015-07-19 22:41:19 +00:00
parent c27d9d0494
commit 95765db7eb

View File

@@ -224,7 +224,7 @@ func (sw *Switch) AddPeerWithConnection(conn net.Conn, outbound bool) (*Peer, er
// ignore if duplicate or if we already have too many for that IP range
if err := sw.peers.Add(peer); err != nil {
log.Info("Ignoring peer", "error", err, "peer", peer)
peer.stop() // will also close sconn
peer.mconn.Stop()
return nil, err
}