mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
rename the methods of the sessionRunner interface
This commit is contained in:
parent
759cd289c9
commit
733dcb75eb
7 changed files with 73 additions and 77 deletions
|
@ -358,9 +358,8 @@ func (c *client) createNewTLSSession(version protocol.VersionNumber) error {
|
|||
c.mutex.Lock()
|
||||
defer c.mutex.Unlock()
|
||||
runner := &runner{
|
||||
packetHandlerManager: c.packetHandlers,
|
||||
onHandshakeCompleteImpl: func(_ Session) { close(c.handshakeChan) },
|
||||
retireConnectionIDImpl: c.packetHandlers.Retire,
|
||||
removeConnectionIDImpl: c.packetHandlers.Remove,
|
||||
}
|
||||
sess, err := newClientSession(
|
||||
c.conn,
|
||||
|
|
|
@ -204,7 +204,7 @@ var _ = Describe("Client", func() {
|
|||
) (quicSession, error) {
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
sess.EXPECT().run().Do(func() { close(run) })
|
||||
runner.onHandshakeComplete(sess)
|
||||
runner.OnHandshakeComplete(sess)
|
||||
return sess, nil
|
||||
}
|
||||
s, err := Dial(
|
||||
|
@ -325,7 +325,7 @@ var _ = Describe("Client", func() {
|
|||
return sess, nil
|
||||
}
|
||||
sess.EXPECT().run().Do(func() {
|
||||
runner.retireConnectionID(connID)
|
||||
runner.Retire(connID)
|
||||
})
|
||||
|
||||
_, err := DialContext(
|
||||
|
|
|
@ -34,38 +34,38 @@ func (m *MockSessionRunner) EXPECT() *MockSessionRunnerMockRecorder {
|
|||
return m.recorder
|
||||
}
|
||||
|
||||
// onHandshakeComplete mocks base method
|
||||
func (m *MockSessionRunner) onHandshakeComplete(arg0 Session) {
|
||||
// OnHandshakeComplete mocks base method
|
||||
func (m *MockSessionRunner) OnHandshakeComplete(arg0 Session) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "onHandshakeComplete", arg0)
|
||||
m.ctrl.Call(m, "OnHandshakeComplete", arg0)
|
||||
}
|
||||
|
||||
// onHandshakeComplete indicates an expected call of onHandshakeComplete
|
||||
func (mr *MockSessionRunnerMockRecorder) onHandshakeComplete(arg0 interface{}) *gomock.Call {
|
||||
// OnHandshakeComplete indicates an expected call of OnHandshakeComplete
|
||||
func (mr *MockSessionRunnerMockRecorder) OnHandshakeComplete(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "onHandshakeComplete", reflect.TypeOf((*MockSessionRunner)(nil).onHandshakeComplete), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnHandshakeComplete", reflect.TypeOf((*MockSessionRunner)(nil).OnHandshakeComplete), arg0)
|
||||
}
|
||||
|
||||
// removeConnectionID mocks base method
|
||||
func (m *MockSessionRunner) removeConnectionID(arg0 protocol.ConnectionID) {
|
||||
// Remove mocks base method
|
||||
func (m *MockSessionRunner) Remove(arg0 protocol.ConnectionID) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "removeConnectionID", arg0)
|
||||
m.ctrl.Call(m, "Remove", arg0)
|
||||
}
|
||||
|
||||
// removeConnectionID indicates an expected call of removeConnectionID
|
||||
func (mr *MockSessionRunnerMockRecorder) removeConnectionID(arg0 interface{}) *gomock.Call {
|
||||
// Remove indicates an expected call of Remove
|
||||
func (mr *MockSessionRunnerMockRecorder) Remove(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "removeConnectionID", reflect.TypeOf((*MockSessionRunner)(nil).removeConnectionID), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Remove", reflect.TypeOf((*MockSessionRunner)(nil).Remove), arg0)
|
||||
}
|
||||
|
||||
// retireConnectionID mocks base method
|
||||
func (m *MockSessionRunner) retireConnectionID(arg0 protocol.ConnectionID) {
|
||||
// Retire mocks base method
|
||||
func (m *MockSessionRunner) Retire(arg0 protocol.ConnectionID) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "retireConnectionID", arg0)
|
||||
m.ctrl.Call(m, "Retire", arg0)
|
||||
}
|
||||
|
||||
// retireConnectionID indicates an expected call of retireConnectionID
|
||||
func (mr *MockSessionRunnerMockRecorder) retireConnectionID(arg0 interface{}) *gomock.Call {
|
||||
// Retire indicates an expected call of Retire
|
||||
func (mr *MockSessionRunnerMockRecorder) Retire(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "retireConnectionID", reflect.TypeOf((*MockSessionRunner)(nil).retireConnectionID), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Retire", reflect.TypeOf((*MockSessionRunner)(nil).Retire), arg0)
|
||||
}
|
||||
|
|
17
server.go
17
server.go
|
@ -52,20 +52,18 @@ type quicSession interface {
|
|||
}
|
||||
|
||||
type sessionRunner interface {
|
||||
onHandshakeComplete(Session)
|
||||
retireConnectionID(protocol.ConnectionID)
|
||||
removeConnectionID(protocol.ConnectionID)
|
||||
OnHandshakeComplete(Session)
|
||||
Retire(protocol.ConnectionID)
|
||||
Remove(protocol.ConnectionID)
|
||||
}
|
||||
|
||||
type runner struct {
|
||||
packetHandlerManager
|
||||
|
||||
onHandshakeCompleteImpl func(Session)
|
||||
retireConnectionIDImpl func(protocol.ConnectionID)
|
||||
removeConnectionIDImpl func(protocol.ConnectionID)
|
||||
}
|
||||
|
||||
func (r *runner) onHandshakeComplete(s Session) { r.onHandshakeCompleteImpl(s) }
|
||||
func (r *runner) retireConnectionID(c protocol.ConnectionID) { r.retireConnectionIDImpl(c) }
|
||||
func (r *runner) removeConnectionID(c protocol.ConnectionID) { r.removeConnectionIDImpl(c) }
|
||||
func (r *runner) OnHandshakeComplete(s Session) { r.onHandshakeCompleteImpl(s) }
|
||||
|
||||
var _ sessionRunner = &runner{}
|
||||
|
||||
|
@ -169,6 +167,7 @@ func listen(conn net.PacketConn, tlsConf *tls.Config, config *Config) (*server,
|
|||
|
||||
func (s *server) setup() error {
|
||||
s.sessionRunner = &runner{
|
||||
packetHandlerManager: s.sessionHandler,
|
||||
onHandshakeCompleteImpl: func(sess Session) {
|
||||
go func() {
|
||||
atomic.AddInt32(&s.sessionQueueLen, 1)
|
||||
|
@ -181,8 +180,6 @@ func (s *server) setup() error {
|
|||
}
|
||||
}()
|
||||
},
|
||||
retireConnectionIDImpl: s.sessionHandler.Retire,
|
||||
removeConnectionIDImpl: s.sessionHandler.Remove,
|
||||
}
|
||||
cookieGenerator, err := handshake.NewCookieGenerator()
|
||||
if err != nil {
|
||||
|
|
|
@ -346,7 +346,7 @@ var _ = Describe("Server", func() {
|
|||
sess.EXPECT().handlePacket(p)
|
||||
sess.EXPECT().run()
|
||||
sess.EXPECT().Context().Return(context.Background())
|
||||
runner.onHandshakeComplete(sess)
|
||||
runner.OnHandshakeComplete(sess)
|
||||
return sess, nil
|
||||
}
|
||||
|
||||
|
@ -403,7 +403,7 @@ var _ = Describe("Server", func() {
|
|||
sess.EXPECT().handlePacket(p)
|
||||
sess.EXPECT().run()
|
||||
sess.EXPECT().Context().Return(ctx)
|
||||
runner.onHandshakeComplete(sess)
|
||||
runner.OnHandshakeComplete(sess)
|
||||
close(sessionCreated)
|
||||
return sess, nil
|
||||
}
|
||||
|
@ -489,7 +489,7 @@ var _ = Describe("Server", func() {
|
|||
) (quicSession, error) {
|
||||
go func() {
|
||||
<-completeHandshake
|
||||
runner.onHandshakeComplete(sess)
|
||||
runner.OnHandshakeComplete(sess)
|
||||
}()
|
||||
sess.EXPECT().run().Do(func() {})
|
||||
sess.EXPECT().Context().Return(context.Background())
|
||||
|
@ -521,7 +521,7 @@ var _ = Describe("Server", func() {
|
|||
sess := NewMockQuicSession(mockCtrl)
|
||||
sess.EXPECT().run().Do(func() {})
|
||||
sess.EXPECT().Context().Return(context.Background())
|
||||
runner.onHandshakeComplete(sess)
|
||||
runner.OnHandshakeComplete(sess)
|
||||
done <- struct{}{}
|
||||
return sess, nil
|
||||
}
|
||||
|
|
|
@ -473,7 +473,7 @@ func (s *session) idleTimeoutStartTime() time.Time {
|
|||
func (s *session) handleHandshakeComplete() {
|
||||
s.handshakeComplete = true
|
||||
s.handshakeCompleteChan = nil // prevent this case from ever being selected again
|
||||
s.sessionRunner.onHandshakeComplete(s)
|
||||
s.sessionRunner.OnHandshakeComplete(s)
|
||||
|
||||
// The client completes the handshake first (after sending the CFIN).
|
||||
// We need to make sure they learn about the peer completing the handshake,
|
||||
|
@ -835,7 +835,7 @@ func (s *session) closeLocal(e error) {
|
|||
} else {
|
||||
s.logger.Errorf("Closing session with error: %s", e)
|
||||
}
|
||||
s.sessionRunner.retireConnectionID(s.srcConnID)
|
||||
s.sessionRunner.Retire(s.srcConnID)
|
||||
s.closeChan <- closeError{err: e, sendClose: true, remote: false}
|
||||
})
|
||||
}
|
||||
|
@ -848,7 +848,7 @@ func (s *session) destroy(e error) {
|
|||
} else {
|
||||
s.logger.Errorf("Destroying session with error: %s", e)
|
||||
}
|
||||
s.sessionRunner.removeConnectionID(s.srcConnID)
|
||||
s.sessionRunner.Remove(s.srcConnID)
|
||||
s.closeChan <- closeError{err: e, sendClose: false, remote: false}
|
||||
})
|
||||
}
|
||||
|
@ -864,7 +864,7 @@ func (s *session) closeForRecreating() protocol.PacketNumber {
|
|||
func (s *session) closeRemote(e error) {
|
||||
s.closeOnce.Do(func() {
|
||||
s.logger.Errorf("Peer closed session with error: %s", e)
|
||||
s.sessionRunner.removeConnectionID(s.srcConnID)
|
||||
s.sessionRunner.Remove(s.srcConnID)
|
||||
s.closeChan <- closeError{err: e, remote: true}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -322,7 +322,7 @@ var _ = Describe("Session", func() {
|
|||
It("handles CONNECTION_CLOSE frames", func() {
|
||||
testErr := qerr.Error(qerr.StreamLimitError, "foobar")
|
||||
streamManager.EXPECT().CloseWithError(testErr)
|
||||
sessionRunner.EXPECT().removeConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Remove(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
|
||||
go func() {
|
||||
|
@ -377,7 +377,7 @@ var _ = Describe("Session", func() {
|
|||
|
||||
It("shuts down without error", func() {
|
||||
streamManager.EXPECT().CloseWithError(qerr.Error(qerr.NoError, ""))
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{raw: []byte("connection close")}, nil)
|
||||
Expect(sess.Close()).To(Succeed())
|
||||
|
@ -389,7 +389,7 @@ var _ = Describe("Session", func() {
|
|||
|
||||
It("only closes once", func() {
|
||||
streamManager.EXPECT().CloseWithError(qerr.Error(qerr.NoError, ""))
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
Expect(sess.Close()).To(Succeed())
|
||||
|
@ -402,7 +402,7 @@ var _ = Describe("Session", func() {
|
|||
It("closes streams with proper error", func() {
|
||||
testErr := errors.New("test error")
|
||||
streamManager.EXPECT().CloseWithError(qerr.Error(0x1337, testErr.Error()))
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
sess.CloseWithError(0x1337, testErr)
|
||||
|
@ -412,7 +412,7 @@ var _ = Describe("Session", func() {
|
|||
|
||||
It("closes the session in order to recreate it", func() {
|
||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
sessionRunner.EXPECT().removeConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Remove(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
sess.closeForRecreating()
|
||||
Expect(mconn.written).To(BeEmpty()) // no CONNECTION_CLOSE or PUBLIC_RESET sent
|
||||
|
@ -423,7 +423,7 @@ var _ = Describe("Session", func() {
|
|||
It("destroys the session", func() {
|
||||
testErr := errors.New("close")
|
||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
sessionRunner.EXPECT().removeConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Remove(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
sess.destroy(testErr)
|
||||
Eventually(areSessionsRunning).Should(BeFalse())
|
||||
|
@ -433,7 +433,7 @@ var _ = Describe("Session", func() {
|
|||
|
||||
It("cancels the context when the run loop exists", func() {
|
||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
returned := make(chan struct{})
|
||||
|
@ -451,7 +451,7 @@ var _ = Describe("Session", func() {
|
|||
|
||||
It("retransmits the CONNECTION_CLOSE packet if packets are arriving late", func() {
|
||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{raw: []byte("foobar")}, nil)
|
||||
sess.Close()
|
||||
|
@ -547,7 +547,7 @@ var _ = Describe("Session", func() {
|
|||
cryptoSetup.EXPECT().RunHandshake().Do(func() { <-sess.Context().Done() })
|
||||
sess.run()
|
||||
}()
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
sess.handlePacket(getPacket(&wire.ExtendedHeader{
|
||||
Header: wire.Header{DestConnectionID: sess.srcConnID},
|
||||
PacketNumberLen: protocol.PacketNumberLen1,
|
||||
|
@ -574,7 +574,7 @@ var _ = Describe("Session", func() {
|
|||
Expect(err).To(MatchError("PROTOCOL_VIOLATION: empty packet"))
|
||||
close(done)
|
||||
}()
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
sess.handlePacket(getPacket(&wire.ExtendedHeader{
|
||||
Header: wire.Header{DestConnectionID: sess.srcConnID},
|
||||
PacketNumberLen: protocol.PacketNumberLen1,
|
||||
|
@ -887,7 +887,7 @@ var _ = Describe("Session", func() {
|
|||
Consistently(mconn.written).Should(HaveLen(2))
|
||||
// make the go routine return
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
sess.Close()
|
||||
Eventually(done).Should(BeClosed())
|
||||
|
@ -914,7 +914,7 @@ var _ = Describe("Session", func() {
|
|||
Consistently(mconn.written).Should(HaveLen(1))
|
||||
// make the go routine return
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
sess.Close()
|
||||
Eventually(done).Should(BeClosed())
|
||||
|
@ -943,7 +943,7 @@ var _ = Describe("Session", func() {
|
|||
Eventually(mconn.written, 2*pacingDelay).Should(HaveLen(2))
|
||||
// make the go routine return
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
sess.Close()
|
||||
Eventually(done).Should(BeClosed())
|
||||
|
@ -969,7 +969,7 @@ var _ = Describe("Session", func() {
|
|||
Eventually(mconn.written).Should(HaveLen(3))
|
||||
// make the go routine return
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
sess.Close()
|
||||
Eventually(done).Should(BeClosed())
|
||||
|
@ -990,7 +990,7 @@ var _ = Describe("Session", func() {
|
|||
sess.scheduleSending() // no packet will get sent
|
||||
Consistently(mconn.written).ShouldNot(Receive())
|
||||
// make the go routine return
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
cryptoSetup.EXPECT().Close()
|
||||
sess.Close()
|
||||
|
@ -1018,7 +1018,7 @@ var _ = Describe("Session", func() {
|
|||
sess.scheduleSending()
|
||||
Eventually(mconn.written).Should(Receive())
|
||||
// make the go routine return
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
cryptoSetup.EXPECT().Close()
|
||||
|
@ -1052,7 +1052,7 @@ var _ = Describe("Session", func() {
|
|||
Eventually(mconn.written).Should(Receive())
|
||||
// make sure the go routine returns
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
sess.Close()
|
||||
|
@ -1064,7 +1064,7 @@ var _ = Describe("Session", func() {
|
|||
It("closes when RunHandshake() errors", func() {
|
||||
testErr := errors.New("crypto setup error")
|
||||
streamManager.EXPECT().CloseWithError(qerr.Error(qerr.InternalError, testErr.Error()))
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
go func() {
|
||||
|
@ -1080,13 +1080,13 @@ var _ = Describe("Session", func() {
|
|||
packer.EXPECT().PackPacket().AnyTimes()
|
||||
go func() {
|
||||
defer GinkgoRecover()
|
||||
sessionRunner.EXPECT().onHandshakeComplete(gomock.Any())
|
||||
sessionRunner.EXPECT().OnHandshakeComplete(gomock.Any())
|
||||
cryptoSetup.EXPECT().RunHandshake()
|
||||
sess.run()
|
||||
}()
|
||||
Consistently(sess.Context().Done()).ShouldNot(BeClosed())
|
||||
// make sure the go routine returns
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
cryptoSetup.EXPECT().Close()
|
||||
|
@ -1097,7 +1097,7 @@ var _ = Describe("Session", func() {
|
|||
It("sends a forward-secure packet when the handshake completes", func() {
|
||||
done := make(chan struct{})
|
||||
gomock.InOrder(
|
||||
sessionRunner.EXPECT().onHandshakeComplete(gomock.Any()),
|
||||
sessionRunner.EXPECT().OnHandshakeComplete(gomock.Any()),
|
||||
packer.EXPECT().PackPacket().DoAndReturn(func() (*packedPacket, error) {
|
||||
defer close(done)
|
||||
return &packedPacket{
|
||||
|
@ -1115,7 +1115,7 @@ var _ = Describe("Session", func() {
|
|||
Eventually(done).Should(BeClosed())
|
||||
//make sure the go routine returns
|
||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
cryptoSetup.EXPECT().Close()
|
||||
Expect(sess.Close()).To(Succeed())
|
||||
|
@ -1131,7 +1131,7 @@ var _ = Describe("Session", func() {
|
|||
close(done)
|
||||
}()
|
||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
cryptoSetup.EXPECT().Close()
|
||||
Expect(sess.Close()).To(Succeed())
|
||||
|
@ -1149,7 +1149,7 @@ var _ = Describe("Session", func() {
|
|||
close(done)
|
||||
}()
|
||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
cryptoSetup.EXPECT().Close()
|
||||
Expect(sess.CloseWithError(0x1337, testErr)).To(Succeed())
|
||||
|
@ -1166,7 +1166,7 @@ var _ = Describe("Session", func() {
|
|||
Expect(err.Error()).To(ContainSubstring("transport parameter"))
|
||||
}()
|
||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
cryptoSetup.EXPECT().Close()
|
||||
sess.processTransportParameters([]byte("invalid"))
|
||||
|
@ -1195,7 +1195,7 @@ var _ = Describe("Session", func() {
|
|||
sess.processTransportParameters(chtp.Marshal())
|
||||
// make the go routine return
|
||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
cryptoSetup.EXPECT().Close()
|
||||
sess.Close()
|
||||
|
@ -1250,7 +1250,7 @@ var _ = Describe("Session", func() {
|
|||
}()
|
||||
Eventually(sent).Should(BeClosed())
|
||||
// make the go routine return
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
cryptoSetup.EXPECT().Close()
|
||||
|
@ -1271,7 +1271,7 @@ var _ = Describe("Session", func() {
|
|||
}()
|
||||
Consistently(mconn.written).ShouldNot(Receive())
|
||||
// make the go routine return
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
cryptoSetup.EXPECT().Close()
|
||||
|
@ -1292,7 +1292,7 @@ var _ = Describe("Session", func() {
|
|||
}()
|
||||
Consistently(mconn.written).ShouldNot(Receive())
|
||||
// make the go routine return
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
cryptoSetup.EXPECT().Close()
|
||||
|
@ -1307,7 +1307,7 @@ var _ = Describe("Session", func() {
|
|||
})
|
||||
|
||||
It("times out due to no network activity", func() {
|
||||
sessionRunner.EXPECT().removeConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Remove(gomock.Any())
|
||||
sess.handshakeComplete = true
|
||||
sess.lastPacketReceivedTime = time.Now().Add(-time.Hour)
|
||||
done := make(chan struct{})
|
||||
|
@ -1327,7 +1327,7 @@ var _ = Describe("Session", func() {
|
|||
|
||||
It("times out due to non-completed handshake", func() {
|
||||
sess.sessionCreationTime = time.Now().Add(-protocol.DefaultHandshakeTimeout).Add(-time.Second)
|
||||
sessionRunner.EXPECT().removeConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Remove(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
|
@ -1359,7 +1359,7 @@ var _ = Describe("Session", func() {
|
|||
}()
|
||||
Consistently(sess.Context().Done()).ShouldNot(BeClosed())
|
||||
// make the go routine return
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
sess.Close()
|
||||
Eventually(sess.Context().Done()).Should(BeClosed())
|
||||
|
@ -1367,13 +1367,13 @@ var _ = Describe("Session", func() {
|
|||
|
||||
It("closes the session due to the idle timeout after handshake", func() {
|
||||
packer.EXPECT().PackPacket().AnyTimes()
|
||||
sessionRunner.EXPECT().removeConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Remove(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
sess.config.IdleTimeout = 0
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer GinkgoRecover()
|
||||
sessionRunner.EXPECT().onHandshakeComplete(sess)
|
||||
sessionRunner.EXPECT().OnHandshakeComplete(sess)
|
||||
cryptoSetup.EXPECT().RunHandshake()
|
||||
err := sess.run()
|
||||
nerr, ok := err.(net.Error)
|
||||
|
@ -1398,7 +1398,7 @@ var _ = Describe("Session", func() {
|
|||
Consistently(sess.Context().Done()).ShouldNot(BeClosed())
|
||||
// make the go routine return
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
sess.Close()
|
||||
Eventually(sess.Context().Done()).Should(BeClosed())
|
||||
|
@ -1573,7 +1573,7 @@ var _ = Describe("Client Session", func() {
|
|||
}, []byte{0}))).To(BeTrue())
|
||||
// make sure the go routine returns
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
cryptoSetup.EXPECT().Close()
|
||||
Expect(sess.Close()).To(Succeed())
|
||||
Eventually(sess.Context().Done()).Should(BeClosed())
|
||||
|
@ -1639,7 +1639,7 @@ var _ = Describe("Client Session", func() {
|
|||
Expect(err.Error()).To(ContainSubstring("transport parameter"))
|
||||
}()
|
||||
// streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
|
||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||
cryptoSetup.EXPECT().Close()
|
||||
sess.processTransportParameters([]byte("invalid"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue