Browse Source

Merge pull request #1338 from tendermint/1266/xla-fix-flaky-testswitchreconnectstopersistentpeer

p2p: Keep reference to connections in test peer
pull/1340/merge
Ethan Buchman 7 years ago
committed by GitHub
parent
commit
eb1816c9ff
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions
  1. +9
    -2
      p2p/peer_test.go

+ 9
- 2
p2p/peer_test.go View File

@ -140,6 +140,8 @@ func (p *remotePeer) Stop() {
}
func (p *remotePeer) accept(l net.Listener) {
conns := []net.Conn{}
for {
conn, err := l.Accept()
if err != nil {
@ -160,10 +162,15 @@ func (p *remotePeer) accept(l net.Listener) {
if err != nil {
golog.Fatalf("Failed to perform handshake: %+v", err)
}
conns = append(conns, conn)
select {
case <-p.quit:
if err := conn.Close(); err != nil {
golog.Fatal(err)
for _, conn := range conns {
if err := conn.Close(); err != nil {
golog.Fatal(err)
}
}
return
default:


Loading…
Cancel
Save