mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 20:57:36 +03:00
add a function to close the packet handler map
Close will close the underlying connection and wait until listen has returned. While not strictly necessary in production use, this will fix a few race conditions in our tests.
This commit is contained in:
parent
6dc4be9f4e
commit
bb185a3ad2
5 changed files with 32 additions and 7 deletions
|
@ -131,6 +131,7 @@ var _ = Describe("Client", func() {
|
|||
|
||||
manager := NewMockPacketHandlerManager(mockCtrl)
|
||||
manager.EXPECT().Add(gomock.Any(), gomock.Any())
|
||||
manager.EXPECT().Close()
|
||||
mockMultiplexer.EXPECT().AddConn(gomock.Any(), gomock.Any()).Return(manager, nil)
|
||||
|
||||
remoteAddrChan := make(chan string, 1)
|
||||
|
@ -162,6 +163,7 @@ var _ = Describe("Client", func() {
|
|||
It("uses the tls.Config.ServerName as the hostname, if present", func() {
|
||||
manager := NewMockPacketHandlerManager(mockCtrl)
|
||||
manager.EXPECT().Add(gomock.Any(), gomock.Any())
|
||||
manager.EXPECT().Close()
|
||||
mockMultiplexer.EXPECT().AddConn(gomock.Any(), gomock.Any()).Return(manager, nil)
|
||||
|
||||
hostnameChan := make(chan string, 1)
|
||||
|
@ -403,12 +405,9 @@ var _ = Describe("Client", func() {
|
|||
// check that the connection is not closed
|
||||
Expect(conn.Write([]byte("foobar"))).To(Succeed())
|
||||
|
||||
manager.EXPECT().Close()
|
||||
close(run)
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
// check that the connection is closed
|
||||
err := conn.Write([]byte("foobar"))
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("use of closed network connection"))
|
||||
|
||||
Eventually(done).Should(BeClosed())
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue