forked from quic-go/quic-go
fix go routine leaks in client tests
This commit is contained in:
@@ -135,8 +135,15 @@ var _ = Describe("Client", func() {
|
|||||||
remoteAddrChan <- conn.RemoteAddr().String()
|
remoteAddrChan <- conn.RemoteAddr().String()
|
||||||
return sess, nil, nil
|
return sess, nil, nil
|
||||||
}
|
}
|
||||||
go DialAddr("localhost:17890", nil, &Config{})
|
dialed := make(chan struct{})
|
||||||
|
go func() {
|
||||||
|
defer GinkgoRecover()
|
||||||
|
DialAddr("localhost:17890", nil, &Config{HandshakeTimeout: time.Millisecond})
|
||||||
|
close(dialed)
|
||||||
|
}()
|
||||||
Eventually(remoteAddrChan).Should(Receive(Equal("127.0.0.1:17890")))
|
Eventually(remoteAddrChan).Should(Receive(Equal("127.0.0.1:17890")))
|
||||||
|
sess.Close(errors.New("peer doesn't reply"))
|
||||||
|
Eventually(dialed).Should(BeClosed())
|
||||||
close(done)
|
close(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -154,8 +161,15 @@ var _ = Describe("Client", func() {
|
|||||||
hostnameChan <- h
|
hostnameChan <- h
|
||||||
return sess, nil, nil
|
return sess, nil, nil
|
||||||
}
|
}
|
||||||
go DialAddr("localhost:17890", &tls.Config{ServerName: "foobar"}, nil)
|
dialed := make(chan struct{})
|
||||||
|
go func() {
|
||||||
|
defer GinkgoRecover()
|
||||||
|
DialAddr("localhost:17890", &tls.Config{ServerName: "foobar"}, nil)
|
||||||
|
close(dialed)
|
||||||
|
}()
|
||||||
Eventually(hostnameChan).Should(Receive(Equal("foobar")))
|
Eventually(hostnameChan).Should(Receive(Equal("foobar")))
|
||||||
|
sess.Close(errors.New("peer doesn't reply"))
|
||||||
|
Eventually(dialed).Should(BeClosed())
|
||||||
close(done)
|
close(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -163,6 +177,7 @@ var _ = Describe("Client", func() {
|
|||||||
testErr := errors.New("early handshake error")
|
testErr := errors.New("early handshake error")
|
||||||
var dialErr error
|
var dialErr error
|
||||||
go func() {
|
go func() {
|
||||||
|
defer GinkgoRecover()
|
||||||
_, dialErr = Dial(packetConn, addr, "quic.clemente.io:1337", nil, config)
|
_, dialErr = Dial(packetConn, addr, "quic.clemente.io:1337", nil, config)
|
||||||
Expect(dialErr).To(MatchError(testErr))
|
Expect(dialErr).To(MatchError(testErr))
|
||||||
close(done)
|
close(done)
|
||||||
@@ -338,15 +353,19 @@ var _ = Describe("Client", func() {
|
|||||||
close(c)
|
close(c)
|
||||||
return sess, nil, nil
|
return sess, nil, nil
|
||||||
}
|
}
|
||||||
|
dialed := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
_, err := Dial(packetConn, addr, "quic.clemente.io:1337", nil, config)
|
defer GinkgoRecover()
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Dial(packetConn, addr, "quic.clemente.io:1337", nil, config)
|
||||||
|
close(dialed)
|
||||||
}()
|
}()
|
||||||
Eventually(c).Should(BeClosed())
|
Eventually(c).Should(BeClosed())
|
||||||
Expect(cconn.(*conn).pconn).To(Equal(packetConn))
|
Expect(cconn.(*conn).pconn).To(Equal(packetConn))
|
||||||
Expect(hostname).To(Equal("quic.clemente.io"))
|
Expect(hostname).To(Equal("quic.clemente.io"))
|
||||||
Expect(version).To(Equal(cl.version))
|
Expect(version).To(Equal(cl.version))
|
||||||
Expect(conf.Versions).To(Equal(config.Versions))
|
Expect(conf.Versions).To(Equal(config.Versions))
|
||||||
|
sess.Close(errors.New("peer doesn't reply"))
|
||||||
|
Eventually(dialed).Should(BeClosed())
|
||||||
close(done)
|
close(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user