mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 20:57:36 +03:00
remove Session.Close()
Session.Close() sends a transport-level error code. Applications should not be able to call this function, but use CloseWithError() instead.
This commit is contained in:
parent
a5120204cc
commit
a93e544c94
29 changed files with 101 additions and 123 deletions
|
@ -3,6 +3,7 @@
|
||||||
## v0.15.0 (unreleased)
|
## v0.15.0 (unreleased)
|
||||||
|
|
||||||
- Add support for 0-RTT.
|
- Add support for 0-RTT.
|
||||||
|
- Remove `Session.Close()`. Applications need to pass an application error code to the transport using `Session.CloseWithError()`.
|
||||||
|
|
||||||
## v0.14.0 (2019-12-04)
|
## v0.14.0 (2019-12-04)
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ var _ = Describe("Benchmarks", func() {
|
||||||
b.RecordValue("transfer rate [MB/s]", float64(dataLen)/1e6/runtime.Seconds())
|
b.RecordValue("transfer rate [MB/s]", float64(dataLen)/1e6/runtime.Seconds())
|
||||||
|
|
||||||
ln.Close()
|
ln.Close()
|
||||||
sess.Close()
|
sess.CloseWithError(0, "")
|
||||||
}, 3)
|
}, 3)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,8 +301,7 @@ func (c *client) establishSecureConnection(ctx context.Context) error {
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
// The session will send a PeerGoingAway error to the server.
|
c.session.shutdown()
|
||||||
c.session.Close()
|
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
case err := <-errorChan:
|
case err := <-errorChan:
|
||||||
return err
|
return err
|
||||||
|
@ -373,13 +372,13 @@ func (c *client) handleVersionNegotiationPacket(p *receivedPacket) {
|
||||||
c.initialPacketNumber = c.session.closeForRecreating()
|
c.initialPacketNumber = c.session.closeForRecreating()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) Close() error {
|
func (c *client) shutdown() {
|
||||||
c.mutex.Lock()
|
c.mutex.Lock()
|
||||||
defer c.mutex.Unlock()
|
defer c.mutex.Unlock()
|
||||||
if c.session == nil {
|
if c.session == nil {
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
return c.session.Close()
|
c.session.shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) destroy(e error) {
|
func (c *client) destroy(e error) {
|
||||||
|
|
|
@ -96,7 +96,7 @@ var _ = Describe("Client", func() {
|
||||||
|
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
if s, ok := cl.session.(*session); ok {
|
if s, ok := cl.session.(*session); ok {
|
||||||
s.Close()
|
s.shutdown()
|
||||||
}
|
}
|
||||||
Eventually(areSessionsRunning).Should(BeFalse())
|
Eventually(areSessionsRunning).Should(BeFalse())
|
||||||
})
|
})
|
||||||
|
@ -387,7 +387,7 @@ var _ = Describe("Client", func() {
|
||||||
close(dialed)
|
close(dialed)
|
||||||
}()
|
}()
|
||||||
Consistently(dialed).ShouldNot(BeClosed())
|
Consistently(dialed).ShouldNot(BeClosed())
|
||||||
sess.EXPECT().Close()
|
sess.EXPECT().shutdown()
|
||||||
cancel()
|
cancel()
|
||||||
Eventually(dialed).Should(BeClosed())
|
Eventually(dialed).Should(BeClosed())
|
||||||
})
|
})
|
||||||
|
|
|
@ -79,9 +79,8 @@ func (s *closedLocalSession) handlePacketImpl(_ *receivedPacket) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *closedLocalSession) Close() error {
|
func (s *closedLocalSession) shutdown() {
|
||||||
s.destroy(nil)
|
s.destroy(nil)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *closedLocalSession) destroy(error) {
|
func (s *closedLocalSession) destroy(error) {
|
||||||
|
@ -108,6 +107,6 @@ func newClosedRemoteSession(pers protocol.Perspective) packetHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *closedRemoteSession) handlePacket(*receivedPacket) {}
|
func (s *closedRemoteSession) handlePacket(*receivedPacket) {}
|
||||||
func (s *closedRemoteSession) Close() error { return nil }
|
func (s *closedRemoteSession) shutdown() {}
|
||||||
func (s *closedRemoteSession) destroy(error) {}
|
func (s *closedRemoteSession) destroy(error) {}
|
||||||
func (s *closedRemoteSession) getPerspective() protocol.Perspective { return s.perspective }
|
func (s *closedRemoteSession) getPerspective() protocol.Perspective { return s.perspective }
|
||||||
|
|
|
@ -30,7 +30,7 @@ var _ = Describe("Closed local session", func() {
|
||||||
It("tells its perspective", func() {
|
It("tells its perspective", func() {
|
||||||
Expect(sess.getPerspective()).To(Equal(protocol.PerspectiveClient))
|
Expect(sess.getPerspective()).To(Equal(protocol.PerspectiveClient))
|
||||||
// stop the session
|
// stop the session
|
||||||
Expect(sess.Close()).To(Succeed())
|
sess.shutdown()
|
||||||
})
|
})
|
||||||
|
|
||||||
It("repeats the packet containing the CONNECTION_CLOSE frame", func() {
|
It("repeats the packet containing the CONNECTION_CLOSE frame", func() {
|
||||||
|
@ -45,7 +45,7 @@ var _ = Describe("Closed local session", func() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// stop the session
|
// stop the session
|
||||||
Expect(sess.Close()).To(Succeed())
|
sess.shutdown()
|
||||||
})
|
})
|
||||||
|
|
||||||
It("destroys sessions", func() {
|
It("destroys sessions", func() {
|
||||||
|
|
|
@ -93,7 +93,7 @@ var _ = Describe("Stream Cancelations", func() {
|
||||||
|
|
||||||
var serverCanceledCounter int32
|
var serverCanceledCounter int32
|
||||||
Eventually(serverCanceledCounterChan).Should(Receive(&serverCanceledCounter))
|
Eventually(serverCanceledCounterChan).Should(Receive(&serverCanceledCounter))
|
||||||
Expect(sess.Close()).To(Succeed())
|
Expect(sess.CloseWithError(0, "")).To(Succeed())
|
||||||
|
|
||||||
clientCanceledCounter := atomic.LoadInt32(&canceledCounter)
|
clientCanceledCounter := atomic.LoadInt32(&canceledCounter)
|
||||||
// The server will only count a stream as being reset if learns about the cancelation before it finished writing all data.
|
// The server will only count a stream as being reset if learns about the cancelation before it finished writing all data.
|
||||||
|
@ -141,7 +141,7 @@ var _ = Describe("Stream Cancelations", func() {
|
||||||
|
|
||||||
var serverCanceledCounter int32
|
var serverCanceledCounter int32
|
||||||
Eventually(serverCanceledCounterChan).Should(Receive(&serverCanceledCounter))
|
Eventually(serverCanceledCounterChan).Should(Receive(&serverCanceledCounter))
|
||||||
Expect(sess.Close()).To(Succeed())
|
Expect(sess.CloseWithError(0, "")).To(Succeed())
|
||||||
|
|
||||||
clientCanceledCounter := atomic.LoadInt32(&canceledCounter)
|
clientCanceledCounter := atomic.LoadInt32(&canceledCounter)
|
||||||
// The server will only count a stream as being reset if learns about the cancelation before it finished writing all data.
|
// The server will only count a stream as being reset if learns about the cancelation before it finished writing all data.
|
||||||
|
@ -185,7 +185,7 @@ var _ = Describe("Stream Cancelations", func() {
|
||||||
fmt.Fprintf(GinkgoWriter, "Canceled writing on %d of %d streams\n", streamCount, numStreams)
|
fmt.Fprintf(GinkgoWriter, "Canceled writing on %d of %d streams\n", streamCount, numStreams)
|
||||||
Expect(streamCount).To(BeNumerically(">", numStreams/10))
|
Expect(streamCount).To(BeNumerically(">", numStreams/10))
|
||||||
Expect(numStreams - streamCount).To(BeNumerically(">", numStreams/10))
|
Expect(numStreams - streamCount).To(BeNumerically(">", numStreams/10))
|
||||||
Expect(sess.Close()).To(Succeed())
|
Expect(sess.CloseWithError(0, "")).To(Succeed())
|
||||||
Expect(server.Close()).To(Succeed())
|
Expect(server.Close()).To(Succeed())
|
||||||
return streamCount
|
return streamCount
|
||||||
}
|
}
|
||||||
|
@ -326,7 +326,7 @@ var _ = Describe("Stream Cancelations", func() {
|
||||||
Expect(count).To(BeNumerically(">", numStreams/15))
|
Expect(count).To(BeNumerically(">", numStreams/15))
|
||||||
fmt.Fprintf(GinkgoWriter, "Successfully read from %d of %d streams.\n", count, numStreams)
|
fmt.Fprintf(GinkgoWriter, "Successfully read from %d of %d streams.\n", count, numStreams)
|
||||||
|
|
||||||
Expect(sess.Close()).To(Succeed())
|
Expect(sess.CloseWithError(0, "")).To(Succeed())
|
||||||
Eventually(done).Should(BeClosed())
|
Eventually(done).Should(BeClosed())
|
||||||
Expect(server.Close()).To(Succeed())
|
Expect(server.Close()).To(Succeed())
|
||||||
})
|
})
|
||||||
|
@ -414,7 +414,7 @@ var _ = Describe("Stream Cancelations", func() {
|
||||||
Expect(count).To(BeNumerically(">", numStreams/15))
|
Expect(count).To(BeNumerically(">", numStreams/15))
|
||||||
fmt.Fprintf(GinkgoWriter, "Successfully read from %d of %d streams.\n", count, numStreams)
|
fmt.Fprintf(GinkgoWriter, "Successfully read from %d of %d streams.\n", count, numStreams)
|
||||||
|
|
||||||
Expect(sess.Close()).To(Succeed())
|
Expect(sess.CloseWithError(0, "")).To(Succeed())
|
||||||
Eventually(done).Should(BeClosed())
|
Eventually(done).Should(BeClosed())
|
||||||
Expect(server.Close()).To(Succeed())
|
Expect(server.Close()).To(Succeed())
|
||||||
})
|
})
|
||||||
|
@ -484,7 +484,7 @@ var _ = Describe("Stream Cancelations", func() {
|
||||||
count := atomic.LoadInt32(&counter)
|
count := atomic.LoadInt32(&counter)
|
||||||
fmt.Fprintf(GinkgoWriter, "Canceled AcceptStream %d times\n", count)
|
fmt.Fprintf(GinkgoWriter, "Canceled AcceptStream %d times\n", count)
|
||||||
Expect(count).To(BeNumerically(">", numStreams/2))
|
Expect(count).To(BeNumerically(">", numStreams/2))
|
||||||
Expect(sess.Close()).To(Succeed())
|
Expect(sess.CloseWithError(0, "")).To(Succeed())
|
||||||
Expect(server.Close()).To(Succeed())
|
Expect(server.Close()).To(Succeed())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -555,7 +555,7 @@ var _ = Describe("Stream Cancelations", func() {
|
||||||
count := atomic.LoadInt32(&numCanceled)
|
count := atomic.LoadInt32(&numCanceled)
|
||||||
fmt.Fprintf(GinkgoWriter, "Canceled OpenStreamSync %d times\n", count)
|
fmt.Fprintf(GinkgoWriter, "Canceled OpenStreamSync %d times\n", count)
|
||||||
Expect(count).To(BeNumerically(">", numStreams/5))
|
Expect(count).To(BeNumerically(">", numStreams/5))
|
||||||
Expect(sess.Close()).To(Succeed())
|
Expect(sess.CloseWithError(0, "")).To(Succeed())
|
||||||
Expect(server.Close()).To(Succeed())
|
Expect(server.Close()).To(Succeed())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -51,7 +51,7 @@ var _ = Describe("Connection ID lengths tests", func() {
|
||||||
conf,
|
conf,
|
||||||
)
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer cl.Close()
|
defer cl.CloseWithError(0, "")
|
||||||
str, err := cl.AcceptStream(context.Background())
|
str, err := cl.AcceptStream(context.Background())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
data, err := ioutil.ReadAll(str)
|
data, err := ioutil.ReadAll(str)
|
||||||
|
|
|
@ -100,7 +100,7 @@ var _ = Describe("Drop Tests", func() {
|
||||||
time.Sleep(messageInterval)
|
time.Sleep(messageInterval)
|
||||||
}
|
}
|
||||||
<-done
|
<-done
|
||||||
Expect(sess.Close()).To(Succeed())
|
Expect(sess.CloseWithError(0, "")).To(Succeed())
|
||||||
}()
|
}()
|
||||||
|
|
||||||
sess, err := quic.DialAddr(
|
sess, err := quic.DialAddr(
|
||||||
|
@ -109,7 +109,7 @@ var _ = Describe("Drop Tests", func() {
|
||||||
&quic.Config{Versions: []protocol.VersionNumber{version}},
|
&quic.Config{Versions: []protocol.VersionNumber{version}},
|
||||||
)
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer sess.Close()
|
defer sess.CloseWithError(0, "")
|
||||||
str, err := sess.AcceptStream(context.Background())
|
str, err := sess.AcceptStream(context.Background())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
for i := uint8(1); i <= numMessages; i++ {
|
for i := uint8(1); i <= numMessages; i++ {
|
||||||
|
|
|
@ -64,7 +64,7 @@ var _ = Describe("early data", func() {
|
||||||
data, err := ioutil.ReadAll(str)
|
data, err := ioutil.ReadAll(str)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(data).To(Equal([]byte("early data")))
|
Expect(data).To(Equal([]byte("early data")))
|
||||||
sess.Close()
|
sess.CloseWithError(0, "")
|
||||||
Eventually(done).Should(BeClosed())
|
Eventually(done).Should(BeClosed())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -67,7 +67,7 @@ var _ = Describe("Handshake drop tests", func() {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
sess, err := ln.Accept(context.Background())
|
sess, err := ln.Accept(context.Background())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer sess.Close()
|
defer sess.CloseWithError(0, "")
|
||||||
str, err := sess.AcceptStream(context.Background())
|
str, err := sess.AcceptStream(context.Background())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
b := make([]byte, 6)
|
b := make([]byte, 6)
|
||||||
|
@ -93,8 +93,8 @@ var _ = Describe("Handshake drop tests", func() {
|
||||||
|
|
||||||
var serverSession quic.Session
|
var serverSession quic.Session
|
||||||
Eventually(serverSessionChan, timeout).Should(Receive(&serverSession))
|
Eventually(serverSessionChan, timeout).Should(Receive(&serverSession))
|
||||||
sess.Close()
|
sess.CloseWithError(0, "")
|
||||||
serverSession.Close()
|
serverSession.CloseWithError(0, "")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,8 +131,8 @@ var _ = Describe("Handshake drop tests", func() {
|
||||||
|
|
||||||
var serverSession quic.Session
|
var serverSession quic.Session
|
||||||
Eventually(serverSessionChan, timeout).Should(Receive(&serverSession))
|
Eventually(serverSessionChan, timeout).Should(Receive(&serverSession))
|
||||||
sess.Close()
|
sess.CloseWithError(0, "")
|
||||||
serverSession.Close()
|
serverSession.CloseWithError(0, "")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,8 +159,8 @@ var _ = Describe("Handshake drop tests", func() {
|
||||||
var serverSession quic.Session
|
var serverSession quic.Session
|
||||||
Eventually(serverSessionChan, timeout).Should(Receive(&serverSession))
|
Eventually(serverSessionChan, timeout).Should(Receive(&serverSession))
|
||||||
// both server and client accepted a session. Close now.
|
// both server and client accepted a session. Close now.
|
||||||
sess.Close()
|
sess.CloseWithError(0, "")
|
||||||
serverSession.Close()
|
serverSession.CloseWithError(0, "")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
)
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(sess.(versioner).GetVersion()).To(Equal(protocol.SupportedVersions[0]))
|
Expect(sess.(versioner).GetVersion()).To(Equal(protocol.SupportedVersions[0]))
|
||||||
Expect(sess.Close()).To(Succeed())
|
Expect(sess.CloseWithError(0, "")).To(Succeed())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("when the client supports more versions than the server supports", func() {
|
It("when the client supports more versions than the server supports", func() {
|
||||||
|
@ -130,7 +130,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
)
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(sess.(versioner).GetVersion()).To(Equal(protocol.SupportedVersions[0]))
|
Expect(sess.(versioner).GetVersion()).To(Equal(protocol.SupportedVersions[0]))
|
||||||
Expect(sess.Close()).To(Succeed())
|
Expect(sess.CloseWithError(0, "")).To(Succeed())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
for i := 0; i < protocol.MaxAcceptQueueSize; i++ {
|
for i := 0; i < protocol.MaxAcceptQueueSize; i++ {
|
||||||
sess, err := dial()
|
sess, err := dial()
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer sess.Close()
|
defer sess.CloseWithError(0, "")
|
||||||
}
|
}
|
||||||
time.Sleep(25 * time.Millisecond) // wait a bit for the sessions to be queued
|
time.Sleep(25 * time.Millisecond) // wait a bit for the sessions to be queued
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
// dial again, and expect that this dial succeeds
|
// dial again, and expect that this dial succeeds
|
||||||
sess, err := dial()
|
sess, err := dial()
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer sess.Close()
|
defer sess.CloseWithError(0, "")
|
||||||
time.Sleep(25 * time.Millisecond) // wait a bit for the session to be queued
|
time.Sleep(25 * time.Millisecond) // wait a bit for the session to be queued
|
||||||
|
|
||||||
_, err = dial()
|
_, err = dial()
|
||||||
|
@ -283,7 +283,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
for i := 1; i < protocol.MaxAcceptQueueSize; i++ {
|
for i := 1; i < protocol.MaxAcceptQueueSize; i++ {
|
||||||
sess, err := dial()
|
sess, err := dial()
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer sess.Close()
|
defer sess.CloseWithError(0, "")
|
||||||
}
|
}
|
||||||
time.Sleep(25 * time.Millisecond) // wait a bit for the sessions to be queued
|
time.Sleep(25 * time.Millisecond) // wait a bit for the sessions to be queued
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
|
|
||||||
// Now close the one of the session that are waiting to be accepted.
|
// Now close the one of the session that are waiting to be accepted.
|
||||||
// This should free one spot in the queue.
|
// This should free one spot in the queue.
|
||||||
Expect(firstSess.Close())
|
Expect(firstSess.CloseWithError(0, ""))
|
||||||
time.Sleep(25 * time.Millisecond)
|
time.Sleep(25 * time.Millisecond)
|
||||||
|
|
||||||
// dial again, and expect that this dial succeeds
|
// dial again, and expect that this dial succeeds
|
||||||
|
@ -330,7 +330,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer sess.Close()
|
defer sess.CloseWithError(0, "")
|
||||||
cs := sess.ConnectionState()
|
cs := sess.ConnectionState()
|
||||||
Expect(cs.NegotiatedProtocol).To(Equal(alpn))
|
Expect(cs.NegotiatedProtocol).To(Equal(alpn))
|
||||||
Expect(cs.NegotiatedProtocolIsMutual).To(BeTrue())
|
Expect(cs.NegotiatedProtocolIsMutual).To(BeTrue())
|
||||||
|
@ -389,7 +389,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
Eventually(puts).Should(Receive())
|
Eventually(puts).Should(Receive())
|
||||||
Expect(tokenChan).ToNot(Receive())
|
Expect(tokenChan).ToNot(Receive())
|
||||||
// received a token. Close this session.
|
// received a token. Close this session.
|
||||||
Expect(sess.Close()).To(Succeed())
|
Expect(sess.CloseWithError(0, "")).To(Succeed())
|
||||||
|
|
||||||
// dial the second session and verify that the token was used
|
// dial the second session and verify that the token was used
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
|
@ -405,7 +405,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
quicConf,
|
quicConf,
|
||||||
)
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer sess.Close()
|
defer sess.CloseWithError(0, "")
|
||||||
Expect(gets).To(Receive())
|
Expect(gets).To(Receive())
|
||||||
Expect(tokenChan).To(Receive())
|
Expect(tokenChan).To(Receive())
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ var _ = Describe("Key Update tests", func() {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer sess.Close()
|
defer sess.CloseWithError(0, "")
|
||||||
str, err := sess.AcceptUniStream(context.Background())
|
str, err := sess.AcceptUniStream(context.Background())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
data, err := ioutil.ReadAll(str)
|
data, err := ioutil.ReadAll(str)
|
||||||
|
|
|
@ -139,7 +139,7 @@ var _ = Describe("MITM test", func() {
|
||||||
data, err := ioutil.ReadAll(str)
|
data, err := ioutil.ReadAll(str)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(data).To(Equal(PRData))
|
Expect(data).To(Equal(PRData))
|
||||||
Expect(sess.Close()).To(Succeed())
|
Expect(sess.CloseWithError(0, "")).To(Succeed())
|
||||||
}
|
}
|
||||||
|
|
||||||
It("downloads a message when the packets are injected towards the server", func() {
|
It("downloads a message when the packets are injected towards the server", func() {
|
||||||
|
@ -185,7 +185,7 @@ var _ = Describe("MITM test", func() {
|
||||||
data, err := ioutil.ReadAll(str)
|
data, err := ioutil.ReadAll(str)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(data).To(Equal(PRData))
|
Expect(data).To(Equal(PRData))
|
||||||
Expect(sess.Close()).To(Succeed())
|
Expect(sess.CloseWithError(0, "")).To(Succeed())
|
||||||
}
|
}
|
||||||
|
|
||||||
Context("duplicating packets", func() {
|
Context("duplicating packets", func() {
|
||||||
|
|
|
@ -49,7 +49,7 @@ var _ = Describe("Multiplexing", func() {
|
||||||
&quic.Config{Versions: []protocol.VersionNumber{version}},
|
&quic.Config{Versions: []protocol.VersionNumber{version}},
|
||||||
)
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer sess.Close()
|
defer sess.CloseWithError(0, "")
|
||||||
str, err := sess.AcceptStream(context.Background())
|
str, err := sess.AcceptStream(context.Background())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
data, err := ioutil.ReadAll(str)
|
data, err := ioutil.ReadAll(str)
|
||||||
|
|
|
@ -72,7 +72,7 @@ var _ = Describe("non-zero RTT", func() {
|
||||||
data, err := ioutil.ReadAll(str)
|
data, err := ioutil.ReadAll(str)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(data).To(Equal(PRData))
|
Expect(data).To(Equal(PRData))
|
||||||
sess.Close()
|
sess.CloseWithError(0, "")
|
||||||
Eventually(done).Should(BeClosed())
|
Eventually(done).Should(BeClosed())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ var _ = Describe("Bidirectional streams", func() {
|
||||||
sess, err := server.Accept(context.Background())
|
sess, err := server.Accept(context.Background())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
runSendingPeer(sess)
|
runSendingPeer(sess)
|
||||||
sess.Close()
|
sess.CloseWithError(0, "")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
client, err := quic.DialAddr(
|
client, err := quic.DialAddr(
|
||||||
|
|
|
@ -75,7 +75,7 @@ var _ = Describe("Unidirectional Streams", func() {
|
||||||
sess, err := server.Accept(context.Background())
|
sess, err := server.Accept(context.Background())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
runReceivingPeer(sess)
|
runReceivingPeer(sess)
|
||||||
sess.Close()
|
sess.CloseWithError(0, "")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
client, err := quic.DialAddr(
|
client, err := quic.DialAddr(
|
||||||
|
|
|
@ -64,7 +64,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Eventually(puts).Should(Receive())
|
Eventually(puts).Should(Receive())
|
||||||
// received the session ticket. We're done here.
|
// received the session ticket. We're done here.
|
||||||
Expect(sess.Close()).To(Succeed())
|
Expect(sess.CloseWithError(0, "")).To(Succeed())
|
||||||
return clientConf
|
return clientConf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,8 +175,6 @@ type Session interface {
|
||||||
LocalAddr() net.Addr
|
LocalAddr() net.Addr
|
||||||
// RemoteAddr returns the address of the peer.
|
// RemoteAddr returns the address of the peer.
|
||||||
RemoteAddr() net.Addr
|
RemoteAddr() net.Addr
|
||||||
// Close the connection.
|
|
||||||
io.Closer
|
|
||||||
// Close the connection with an error.
|
// Close the connection with an error.
|
||||||
// The error string will be sent to the peer.
|
// The error string will be sent to the peer.
|
||||||
CloseWithError(ErrorCode, string) error
|
CloseWithError(ErrorCode, string) error
|
||||||
|
|
|
@ -68,20 +68,6 @@ func (mr *MockSessionMockRecorder) AcceptUniStream(arg0 interface{}) *gomock.Cal
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcceptUniStream", reflect.TypeOf((*MockSession)(nil).AcceptUniStream), arg0)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcceptUniStream", reflect.TypeOf((*MockSession)(nil).AcceptUniStream), arg0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close mocks base method
|
|
||||||
func (m *MockSession) Close() error {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "Close")
|
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close indicates an expected call of Close
|
|
||||||
func (mr *MockSessionMockRecorder) Close() *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockSession)(nil).Close))
|
|
||||||
}
|
|
||||||
|
|
||||||
// CloseWithError mocks base method
|
// CloseWithError mocks base method
|
||||||
func (m *MockSession) CloseWithError(arg0 protocol.ApplicationErrorCode, arg1 string) error {
|
func (m *MockSession) CloseWithError(arg0 protocol.ApplicationErrorCode, arg1 string) error {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
|
|
|
@ -116,7 +116,7 @@ func (c *client) Close() error {
|
||||||
if c.sess == nil {
|
if c.sess == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return c.sess.Close()
|
return c.sess.CloseWithError(0, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func hostnameFromRequest(req *http.Request) string {
|
func hostnameFromRequest(req *http.Request) string {
|
||||||
|
|
|
@ -34,20 +34,6 @@ func (m *MockPacketHandler) EXPECT() *MockPacketHandlerMockRecorder {
|
||||||
return m.recorder
|
return m.recorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close mocks base method
|
|
||||||
func (m *MockPacketHandler) Close() error {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "Close")
|
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close indicates an expected call of Close
|
|
||||||
func (mr *MockPacketHandlerMockRecorder) Close() *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockPacketHandler)(nil).Close))
|
|
||||||
}
|
|
||||||
|
|
||||||
// destroy mocks base method
|
// destroy mocks base method
|
||||||
func (m *MockPacketHandler) destroy(arg0 error) {
|
func (m *MockPacketHandler) destroy(arg0 error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
|
@ -85,3 +71,15 @@ func (mr *MockPacketHandlerMockRecorder) handlePacket(arg0 interface{}) *gomock.
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "handlePacket", reflect.TypeOf((*MockPacketHandler)(nil).handlePacket), arg0)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "handlePacket", reflect.TypeOf((*MockPacketHandler)(nil).handlePacket), arg0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// shutdown mocks base method
|
||||||
|
func (m *MockPacketHandler) shutdown() {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
m.ctrl.Call(m, "shutdown")
|
||||||
|
}
|
||||||
|
|
||||||
|
// shutdown indicates an expected call of shutdown
|
||||||
|
func (mr *MockPacketHandlerMockRecorder) shutdown() *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "shutdown", reflect.TypeOf((*MockPacketHandler)(nil).shutdown))
|
||||||
|
}
|
||||||
|
|
|
@ -67,20 +67,6 @@ func (mr *MockQuicSessionMockRecorder) AcceptUniStream(arg0 interface{}) *gomock
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcceptUniStream", reflect.TypeOf((*MockQuicSession)(nil).AcceptUniStream), arg0)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcceptUniStream", reflect.TypeOf((*MockQuicSession)(nil).AcceptUniStream), arg0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close mocks base method
|
|
||||||
func (m *MockQuicSession) Close() error {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "Close")
|
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close indicates an expected call of Close
|
|
||||||
func (mr *MockQuicSessionMockRecorder) Close() *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockQuicSession)(nil).Close))
|
|
||||||
}
|
|
||||||
|
|
||||||
// CloseWithError mocks base method
|
// CloseWithError mocks base method
|
||||||
func (m *MockQuicSession) CloseWithError(arg0 protocol.ApplicationErrorCode, arg1 string) error {
|
func (m *MockQuicSession) CloseWithError(arg0 protocol.ApplicationErrorCode, arg1 string) error {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
|
@ -318,3 +304,15 @@ func (mr *MockQuicSessionMockRecorder) run() *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "run", reflect.TypeOf((*MockQuicSession)(nil).run))
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "run", reflect.TypeOf((*MockQuicSession)(nil).run))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// shutdown mocks base method
|
||||||
|
func (m *MockQuicSession) shutdown() {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
m.ctrl.Call(m, "shutdown")
|
||||||
|
}
|
||||||
|
|
||||||
|
// shutdown indicates an expected call of shutdown
|
||||||
|
func (mr *MockQuicSessionMockRecorder) shutdown() *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "shutdown", reflect.TypeOf((*MockQuicSession)(nil).shutdown))
|
||||||
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ func (h *packetHandlerMap) ReplaceWithClosed(id protocol.ConnectionID, handler p
|
||||||
|
|
||||||
time.AfterFunc(h.deleteRetiredSessionsAfter, func() {
|
time.AfterFunc(h.deleteRetiredSessionsAfter, func() {
|
||||||
h.mutex.Lock()
|
h.mutex.Lock()
|
||||||
handler.Close()
|
handler.shutdown()
|
||||||
delete(h.handlers, string(id))
|
delete(h.handlers, string(id))
|
||||||
h.mutex.Unlock()
|
h.mutex.Unlock()
|
||||||
})
|
})
|
||||||
|
@ -175,8 +175,8 @@ func (h *packetHandlerMap) CloseServer() {
|
||||||
if handler.getPerspective() == protocol.PerspectiveServer {
|
if handler.getPerspective() == protocol.PerspectiveServer {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(handler packetHandler) {
|
go func(handler packetHandler) {
|
||||||
// session.Close() blocks until the CONNECTION_CLOSE has been sent and the run-loop has stopped
|
// blocks until the CONNECTION_CLOSE has been sent and the run-loop has stopped
|
||||||
_ = handler.Close()
|
handler.shutdown()
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}(handler)
|
}(handler)
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ var _ = Describe("Packet Handler Map", func() {
|
||||||
clientSess.EXPECT().getPerspective().Return(protocol.PerspectiveClient)
|
clientSess.EXPECT().getPerspective().Return(protocol.PerspectiveClient)
|
||||||
serverSess := NewMockPacketHandler(mockCtrl)
|
serverSess := NewMockPacketHandler(mockCtrl)
|
||||||
serverSess.EXPECT().getPerspective().Return(protocol.PerspectiveServer)
|
serverSess.EXPECT().getPerspective().Return(protocol.PerspectiveServer)
|
||||||
serverSess.EXPECT().Close()
|
serverSess.EXPECT().shutdown()
|
||||||
|
|
||||||
handler.Add(protocol.ConnectionID{1, 1, 1, 1}, clientSess)
|
handler.Add(protocol.ConnectionID{1, 1, 1, 1}, clientSess)
|
||||||
handler.Add(protocol.ConnectionID{2, 2, 2, 2}, serverSess)
|
handler.Add(protocol.ConnectionID{2, 2, 2, 2}, serverSess)
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
@ -22,7 +21,7 @@ import (
|
||||||
// packetHandler handles packets
|
// packetHandler handles packets
|
||||||
type packetHandler interface {
|
type packetHandler interface {
|
||||||
handlePacket(*receivedPacket)
|
handlePacket(*receivedPacket)
|
||||||
io.Closer
|
shutdown()
|
||||||
destroy(error)
|
destroy(error)
|
||||||
getPerspective() protocol.Perspective
|
getPerspective() protocol.Perspective
|
||||||
}
|
}
|
||||||
|
@ -49,6 +48,7 @@ type quicSession interface {
|
||||||
getPerspective() protocol.Perspective
|
getPerspective() protocol.Perspective
|
||||||
run() error
|
run() error
|
||||||
destroy(error)
|
destroy(error)
|
||||||
|
shutdown()
|
||||||
closeForRecreating() protocol.PacketNumber
|
closeForRecreating() protocol.PacketNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1063,12 +1063,11 @@ func (s *session) closeRemote(e error) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the connection. It sends a qerr.NoError.
|
// Close the connection. It sends a NO_ERROR transport error.
|
||||||
// It waits until the run loop has stopped before returning
|
// It waits until the run loop has stopped before returning
|
||||||
func (s *session) Close() error {
|
func (s *session) shutdown() {
|
||||||
s.closeLocal(nil)
|
s.closeLocal(nil)
|
||||||
<-s.ctx.Done()
|
<-s.ctx.Done()
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *session) CloseWithError(code protocol.ApplicationErrorCode, desc string) error {
|
func (s *session) CloseWithError(code protocol.ApplicationErrorCode, desc string) error {
|
||||||
|
|
|
@ -67,7 +67,7 @@ var _ = Describe("Session", func() {
|
||||||
sessionRunner.EXPECT().ReplaceWithClosed(clientDestConnID, gomock.Any()).MaxTimes(1)
|
sessionRunner.EXPECT().ReplaceWithClosed(clientDestConnID, gomock.Any()).MaxTimes(1)
|
||||||
sessionRunner.EXPECT().ReplaceWithClosed(srcConnID, gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) {
|
sessionRunner.EXPECT().ReplaceWithClosed(srcConnID, gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) {
|
||||||
Expect(s).To(BeAssignableToTypeOf(&closedLocalSession{}))
|
Expect(s).To(BeAssignableToTypeOf(&closedLocalSession{}))
|
||||||
Expect(s.Close()).To(Succeed())
|
s.shutdown()
|
||||||
Eventually(areClosedSessionsRunning).Should(BeFalse())
|
Eventually(areClosedSessionsRunning).Should(BeFalse())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -423,7 +423,7 @@ var _ = Describe("Session", func() {
|
||||||
return &packedPacket{raw: []byte("connection close")}, nil
|
return &packedPacket{raw: []byte("connection close")}, nil
|
||||||
})
|
})
|
||||||
mconn.EXPECT().Write([]byte("connection close"))
|
mconn.EXPECT().Write([]byte("connection close"))
|
||||||
Expect(sess.Close()).To(Succeed())
|
sess.shutdown()
|
||||||
Eventually(areSessionsRunning).Should(BeFalse())
|
Eventually(areSessionsRunning).Should(BeFalse())
|
||||||
Expect(sess.Context().Done()).To(BeClosed())
|
Expect(sess.Context().Done()).To(BeClosed())
|
||||||
})
|
})
|
||||||
|
@ -434,8 +434,8 @@ var _ = Describe("Session", func() {
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||||
mconn.EXPECT().Write(gomock.Any())
|
mconn.EXPECT().Write(gomock.Any())
|
||||||
Expect(sess.Close()).To(Succeed())
|
sess.shutdown()
|
||||||
Expect(sess.Close()).To(Succeed())
|
sess.shutdown()
|
||||||
Eventually(areSessionsRunning).Should(BeFalse())
|
Eventually(areSessionsRunning).Should(BeFalse())
|
||||||
Expect(sess.Context().Done()).To(BeClosed())
|
Expect(sess.Context().Done()).To(BeClosed())
|
||||||
})
|
})
|
||||||
|
@ -527,7 +527,7 @@ var _ = Describe("Session", func() {
|
||||||
}()
|
}()
|
||||||
Consistently(returned).ShouldNot(BeClosed())
|
Consistently(returned).ShouldNot(BeClosed())
|
||||||
mconn.EXPECT().Write(gomock.Any())
|
mconn.EXPECT().Write(gomock.Any())
|
||||||
sess.Close()
|
sess.shutdown()
|
||||||
Eventually(returned).Should(BeClosed())
|
Eventually(returned).Should(BeClosed())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -666,7 +666,7 @@ var _ = Describe("Session", func() {
|
||||||
Consistently(runErr).ShouldNot(Receive())
|
Consistently(runErr).ShouldNot(Receive())
|
||||||
// make the go routine return
|
// make the go routine return
|
||||||
mconn.EXPECT().Write(gomock.Any())
|
mconn.EXPECT().Write(gomock.Any())
|
||||||
sess.Close()
|
sess.shutdown()
|
||||||
Eventually(sess.Context().Done()).Should(BeClosed())
|
Eventually(sess.Context().Done()).Should(BeClosed())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -877,7 +877,7 @@ var _ = Describe("Session", func() {
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any())
|
mconn.EXPECT().Write(gomock.Any())
|
||||||
sess.Close()
|
sess.shutdown()
|
||||||
Eventually(sess.Context().Done()).Should(BeClosed())
|
Eventually(sess.Context().Done()).Should(BeClosed())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1004,7 +1004,7 @@ var _ = Describe("Session", func() {
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any())
|
mconn.EXPECT().Write(gomock.Any())
|
||||||
Expect(sess.Close()).To(Succeed())
|
sess.shutdown()
|
||||||
Eventually(sess.Context().Done()).Should(BeClosed())
|
Eventually(sess.Context().Done()).Should(BeClosed())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1118,7 +1118,7 @@ var _ = Describe("Session", func() {
|
||||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any())
|
mconn.EXPECT().Write(gomock.Any())
|
||||||
sess.Close()
|
sess.shutdown()
|
||||||
Eventually(sess.Context().Done()).Should(BeClosed())
|
Eventually(sess.Context().Done()).Should(BeClosed())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1206,7 +1206,7 @@ var _ = Describe("Session", func() {
|
||||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any())
|
mconn.EXPECT().Write(gomock.Any())
|
||||||
Expect(sess.Close()).To(Succeed())
|
sess.shutdown()
|
||||||
Eventually(sess.Context().Done()).Should(BeClosed())
|
Eventually(sess.Context().Done()).Should(BeClosed())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1259,7 +1259,7 @@ var _ = Describe("Session", func() {
|
||||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any())
|
mconn.EXPECT().Write(gomock.Any())
|
||||||
Expect(sess.Close()).To(Succeed())
|
sess.shutdown()
|
||||||
Eventually(sess.Context().Done()).Should(BeClosed())
|
Eventually(sess.Context().Done()).Should(BeClosed())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1276,7 +1276,7 @@ var _ = Describe("Session", func() {
|
||||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any())
|
mconn.EXPECT().Write(gomock.Any())
|
||||||
Expect(sess.Close()).To(Succeed())
|
sess.shutdown()
|
||||||
Eventually(done).Should(BeClosed())
|
Eventually(done).Should(BeClosed())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1326,12 +1326,12 @@ var _ = Describe("Session", func() {
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
sessionRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) {
|
sessionRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) {
|
||||||
Expect(s).To(BeAssignableToTypeOf(&closedLocalSession{}))
|
Expect(s).To(BeAssignableToTypeOf(&closedLocalSession{}))
|
||||||
Expect(s.Close()).To(Succeed())
|
s.shutdown()
|
||||||
}).Times(4) // initial connection ID + initial client dest conn ID + 2 newly issued conn IDs
|
}).Times(4) // initial connection ID + initial client dest conn ID + 2 newly issued conn IDs
|
||||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any())
|
mconn.EXPECT().Write(gomock.Any())
|
||||||
Expect(sess.Close()).To(Succeed())
|
sess.shutdown()
|
||||||
Eventually(sess.Context().Done()).Should(BeClosed())
|
Eventually(sess.Context().Done()).Should(BeClosed())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1363,7 +1363,7 @@ var _ = Describe("Session", func() {
|
||||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any())
|
mconn.EXPECT().Write(gomock.Any())
|
||||||
Expect(sess.Close()).To(Succeed())
|
sess.shutdown()
|
||||||
Eventually(sess.Context().Done()).Should(BeClosed())
|
Eventually(sess.Context().Done()).Should(BeClosed())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1477,7 +1477,7 @@ var _ = Describe("Session", func() {
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any())
|
mconn.EXPECT().Write(gomock.Any())
|
||||||
Expect(sess.Close()).To(Succeed())
|
sess.shutdown()
|
||||||
Eventually(sess.Context().Done()).Should(BeClosed())
|
Eventually(sess.Context().Done()).Should(BeClosed())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1521,7 +1521,7 @@ var _ = Describe("Session", func() {
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any())
|
mconn.EXPECT().Write(gomock.Any())
|
||||||
sess.Close()
|
sess.shutdown()
|
||||||
Eventually(sess.Context().Done()).Should(BeClosed())
|
Eventually(sess.Context().Done()).Should(BeClosed())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1625,7 +1625,7 @@ var _ = Describe("Client Session", func() {
|
||||||
|
|
||||||
expectReplaceWithClosed := func() {
|
expectReplaceWithClosed := func() {
|
||||||
sessionRunner.EXPECT().ReplaceWithClosed(srcConnID, gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) {
|
sessionRunner.EXPECT().ReplaceWithClosed(srcConnID, gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) {
|
||||||
Expect(s.Close()).To(Succeed())
|
s.shutdown()
|
||||||
Eventually(areClosedSessionsRunning).Should(BeFalse())
|
Eventually(areClosedSessionsRunning).Should(BeFalse())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1695,7 +1695,7 @@ var _ = Describe("Client Session", func() {
|
||||||
expectReplaceWithClosed()
|
expectReplaceWithClosed()
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
mconn.EXPECT().Write(gomock.Any())
|
mconn.EXPECT().Write(gomock.Any())
|
||||||
Expect(sess.Close()).To(Succeed())
|
sess.shutdown()
|
||||||
Eventually(sess.Context().Done()).Should(BeClosed())
|
Eventually(sess.Context().Done()).Should(BeClosed())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1814,7 +1814,7 @@ var _ = Describe("Client Session", func() {
|
||||||
if !closed {
|
if !closed {
|
||||||
sessionRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) {
|
sessionRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) {
|
||||||
Expect(s).To(BeAssignableToTypeOf(&closedLocalSession{}))
|
Expect(s).To(BeAssignableToTypeOf(&closedLocalSession{}))
|
||||||
Expect(s.Close()).To(Succeed())
|
s.shutdown()
|
||||||
})
|
})
|
||||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil).MaxTimes(1)
|
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil).MaxTimes(1)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
|
@ -1825,7 +1825,7 @@ var _ = Describe("Client Session", func() {
|
||||||
|
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
expectClose()
|
expectClose()
|
||||||
sess.Close()
|
sess.shutdown()
|
||||||
Eventually(sess.Context().Done()).Should(BeClosed())
|
Eventually(sess.Context().Done()).Should(BeClosed())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue