rename removing of connection IDs to retiring

This commit is contained in:
Marten Seemann 2018-11-13 14:14:05 +07:00
parent c8ae4fada0
commit a3831b2134
9 changed files with 56 additions and 56 deletions

View file

@ -406,7 +406,7 @@ func (c *client) createNewTLSSession(version protocol.VersionNumber) error {
defer c.mutex.Unlock() defer c.mutex.Unlock()
runner := &runner{ runner := &runner{
onHandshakeCompleteImpl: func(_ Session) { close(c.handshakeChan) }, onHandshakeCompleteImpl: func(_ Session) { close(c.handshakeChan) },
removeConnectionIDImpl: c.packetHandlers.Remove, retireConnectionIDImpl: c.packetHandlers.Retire,
} }
sess, err := newClientSession( sess, err := newClientSession(
c.conn, c.conn,

View file

@ -311,7 +311,7 @@ var _ = Describe("Client", func() {
It("removes closed sessions from the multiplexer", func() { It("removes closed sessions from the multiplexer", func() {
manager := NewMockPacketHandlerManager(mockCtrl) manager := NewMockPacketHandlerManager(mockCtrl)
manager.EXPECT().Add(connID, gomock.Any()) manager.EXPECT().Add(connID, gomock.Any())
manager.EXPECT().Remove(connID) manager.EXPECT().Retire(connID)
mockMultiplexer.EXPECT().AddConn(packetConn, gomock.Any()).Return(manager, nil) mockMultiplexer.EXPECT().AddConn(packetConn, gomock.Any()).Return(manager, nil)
var runner sessionRunner var runner sessionRunner
@ -334,7 +334,7 @@ var _ = Describe("Client", func() {
return sess, nil return sess, nil
} }
sess.EXPECT().run().Do(func() { sess.EXPECT().run().Do(func() {
runner.removeConnectionID(connID) runner.retireConnectionID(connID)
}) })
_, err := DialContext( _, err := DialContext(

View file

@ -54,14 +54,14 @@ func (mr *MockPacketHandlerManagerMockRecorder) CloseServer() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseServer", reflect.TypeOf((*MockPacketHandlerManager)(nil).CloseServer)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseServer", reflect.TypeOf((*MockPacketHandlerManager)(nil).CloseServer))
} }
// Remove mocks base method // Retire mocks base method
func (m *MockPacketHandlerManager) Remove(arg0 protocol.ConnectionID) { func (m *MockPacketHandlerManager) Retire(arg0 protocol.ConnectionID) {
m.ctrl.Call(m, "Remove", arg0) m.ctrl.Call(m, "Retire", arg0)
} }
// Remove indicates an expected call of Remove // Retire indicates an expected call of Retire
func (mr *MockPacketHandlerManagerMockRecorder) Remove(arg0 interface{}) *gomock.Call { func (mr *MockPacketHandlerManagerMockRecorder) Retire(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Remove", reflect.TypeOf((*MockPacketHandlerManager)(nil).Remove), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Retire", reflect.TypeOf((*MockPacketHandlerManager)(nil).Retire), arg0)
} }
// SetServer mocks base method // SetServer mocks base method

View file

@ -44,12 +44,12 @@ func (mr *MockSessionRunnerMockRecorder) onHandshakeComplete(arg0 interface{}) *
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 // retireConnectionID mocks base method
func (m *MockSessionRunner) removeConnectionID(arg0 protocol.ConnectionID) { func (m *MockSessionRunner) retireConnectionID(arg0 protocol.ConnectionID) {
m.ctrl.Call(m, "removeConnectionID", arg0) m.ctrl.Call(m, "retireConnectionID", arg0)
} }
// removeConnectionID indicates an expected call of removeConnectionID // retireConnectionID indicates an expected call of retireConnectionID
func (mr *MockSessionRunnerMockRecorder) removeConnectionID(arg0 interface{}) *gomock.Call { func (mr *MockSessionRunnerMockRecorder) retireConnectionID(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "removeConnectionID", reflect.TypeOf((*MockSessionRunner)(nil).removeConnectionID), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "retireConnectionID", reflect.TypeOf((*MockSessionRunner)(nil).retireConnectionID), arg0)
} }

View file

@ -51,11 +51,11 @@ func (h *packetHandlerMap) Add(id protocol.ConnectionID, handler packetHandler)
h.mutex.Unlock() h.mutex.Unlock()
} }
func (h *packetHandlerMap) Remove(id protocol.ConnectionID) { func (h *packetHandlerMap) Retire(id protocol.ConnectionID) {
h.removeByConnectionIDAsString(string(id)) h.retireByConnectionIDAsString(string(id))
} }
func (h *packetHandlerMap) removeByConnectionIDAsString(id string) { func (h *packetHandlerMap) retireByConnectionIDAsString(id string) {
time.AfterFunc(h.deleteClosedSessionsAfter, func() { time.AfterFunc(h.deleteClosedSessionsAfter, func() {
h.mutex.Lock() h.mutex.Lock()
delete(h.handlers, id) delete(h.handlers, id)
@ -79,7 +79,7 @@ func (h *packetHandlerMap) CloseServer() {
go func(id string, handler packetHandler) { go func(id string, handler packetHandler) {
// session.Close() blocks until the CONNECTION_CLOSE has been sent and the run-loop has stopped // session.Close() blocks until the CONNECTION_CLOSE has been sent and the run-loop has stopped
_ = handler.Close() _ = handler.Close()
h.removeByConnectionIDAsString(id) h.retireByConnectionIDAsString(id)
wg.Done() wg.Done()
}(id, handler) }(id, handler)
} }

View file

@ -92,7 +92,7 @@ var _ = Describe("Packet Handler Map", func() {
handler.deleteClosedSessionsAfter = 10 * time.Millisecond handler.deleteClosedSessionsAfter = 10 * time.Millisecond
connID := protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8} connID := protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8}
handler.Add(connID, NewMockPacketHandler(mockCtrl)) handler.Add(connID, NewMockPacketHandler(mockCtrl))
handler.Remove(connID) handler.Retire(connID)
time.Sleep(30 * time.Millisecond) time.Sleep(30 * time.Millisecond)
Expect(handler.handlePacket(nil, getPacket(connID))).To(MatchError("received a packet with an unexpected connection ID 0x0102030405060708")) Expect(handler.handlePacket(nil, getPacket(connID))).To(MatchError("received a packet with an unexpected connection ID 0x0102030405060708"))
}) })
@ -105,7 +105,7 @@ var _ = Describe("Packet Handler Map", func() {
packetHandler.EXPECT().GetPerspective().Return(protocol.PerspectiveClient) packetHandler.EXPECT().GetPerspective().Return(protocol.PerspectiveClient)
packetHandler.EXPECT().handlePacket(gomock.Any()) packetHandler.EXPECT().handlePacket(gomock.Any())
handler.Add(connID, packetHandler) handler.Add(connID, packetHandler)
handler.Remove(connID) handler.Retire(connID)
err := handler.handlePacket(nil, getPacket(connID)) err := handler.handlePacket(nil, getPacket(connID))
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })

View file

@ -32,8 +32,8 @@ type unknownPacketHandler interface {
type packetHandlerManager interface { type packetHandlerManager interface {
Add(protocol.ConnectionID, packetHandler) Add(protocol.ConnectionID, packetHandler)
Retire(protocol.ConnectionID)
SetServer(unknownPacketHandler) SetServer(unknownPacketHandler)
Remove(protocol.ConnectionID)
CloseServer() CloseServer()
} }
@ -48,16 +48,16 @@ type quicSession interface {
type sessionRunner interface { type sessionRunner interface {
onHandshakeComplete(Session) onHandshakeComplete(Session)
removeConnectionID(protocol.ConnectionID) retireConnectionID(protocol.ConnectionID)
} }
type runner struct { type runner struct {
onHandshakeCompleteImpl func(Session) onHandshakeCompleteImpl func(Session)
removeConnectionIDImpl func(protocol.ConnectionID) retireConnectionIDImpl func(protocol.ConnectionID)
} }
func (r *runner) onHandshakeComplete(s Session) { r.onHandshakeCompleteImpl(s) } func (r *runner) onHandshakeComplete(s Session) { r.onHandshakeCompleteImpl(s) }
func (r *runner) removeConnectionID(c protocol.ConnectionID) { r.removeConnectionIDImpl(c) } func (r *runner) retireConnectionID(c protocol.ConnectionID) { r.retireConnectionIDImpl(c) }
var _ sessionRunner = &runner{} var _ sessionRunner = &runner{}
@ -152,7 +152,7 @@ func listen(conn net.PacketConn, tlsConf *tls.Config, config *Config) (*server,
func (s *server) setup() error { func (s *server) setup() error {
s.sessionRunner = &runner{ s.sessionRunner = &runner{
onHandshakeCompleteImpl: func(sess Session) { s.sessionQueue <- sess }, onHandshakeCompleteImpl: func(sess Session) { s.sessionQueue <- sess },
removeConnectionIDImpl: s.sessionHandler.Remove, retireConnectionIDImpl: s.sessionHandler.Retire,
} }
cookieGenerator, err := handshake.NewCookieGenerator() cookieGenerator, err := handshake.NewCookieGenerator()
if err != nil { if err != nil {

View file

@ -424,7 +424,7 @@ runLoop:
} }
s.closed.Set(true) s.closed.Set(true)
s.logger.Infof("Connection %s closed.", s.srcConnID) s.logger.Infof("Connection %s closed.", s.srcConnID)
s.sessionRunner.removeConnectionID(s.srcConnID) s.sessionRunner.retireConnectionID(s.srcConnID)
s.cryptoStreamHandler.Close() s.cryptoStreamHandler.Close()
return closeErr.err return closeErr.err
} }

View file

@ -326,7 +326,7 @@ var _ = Describe("Session", func() {
It("handles CONNECTION_CLOSE frames", func() { It("handles CONNECTION_CLOSE frames", func() {
testErr := qerr.Error(qerr.ProofInvalid, "foobar") testErr := qerr.Error(qerr.ProofInvalid, "foobar")
streamManager.EXPECT().CloseWithError(testErr) streamManager.EXPECT().CloseWithError(testErr)
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
go func() { go func() {
@ -367,7 +367,7 @@ var _ = Describe("Session", func() {
It("shuts down without error", func() { It("shuts down without error", func() {
streamManager.EXPECT().CloseWithError(qerr.Error(qerr.PeerGoingAway, "")) streamManager.EXPECT().CloseWithError(qerr.Error(qerr.PeerGoingAway, ""))
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{raw: []byte("connection close")}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{raw: []byte("connection close")}, nil)
Expect(sess.Close()).To(Succeed()) Expect(sess.Close()).To(Succeed())
@ -379,7 +379,7 @@ var _ = Describe("Session", func() {
It("only closes once", func() { It("only closes once", func() {
streamManager.EXPECT().CloseWithError(qerr.Error(qerr.PeerGoingAway, "")) streamManager.EXPECT().CloseWithError(qerr.Error(qerr.PeerGoingAway, ""))
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
Expect(sess.Close()).To(Succeed()) Expect(sess.Close()).To(Succeed())
@ -392,7 +392,7 @@ var _ = Describe("Session", func() {
It("closes streams with proper error", func() { It("closes streams with proper error", func() {
testErr := errors.New("test error") testErr := errors.New("test error")
streamManager.EXPECT().CloseWithError(qerr.Error(0x1337, testErr.Error())) streamManager.EXPECT().CloseWithError(qerr.Error(0x1337, testErr.Error()))
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
sess.CloseWithError(0x1337, testErr) sess.CloseWithError(0x1337, testErr)
@ -402,7 +402,7 @@ var _ = Describe("Session", func() {
It("closes the session in order to replace it with another QUIC version", func() { It("closes the session in order to replace it with another QUIC version", func() {
streamManager.EXPECT().CloseWithError(gomock.Any()) streamManager.EXPECT().CloseWithError(gomock.Any())
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
sess.destroy(errCloseSessionForNewVersion) sess.destroy(errCloseSessionForNewVersion)
Eventually(areSessionsRunning).Should(BeFalse()) Eventually(areSessionsRunning).Should(BeFalse())
@ -411,7 +411,7 @@ var _ = Describe("Session", func() {
It("cancels the context when the run loop exists", func() { It("cancels the context when the run loop exists", func() {
streamManager.EXPECT().CloseWithError(gomock.Any()) streamManager.EXPECT().CloseWithError(gomock.Any())
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
returned := make(chan struct{}) returned := make(chan struct{})
@ -429,7 +429,7 @@ var _ = Describe("Session", func() {
It("retransmits the CONNECTION_CLOSE packet if packets are arriving late", func() { It("retransmits the CONNECTION_CLOSE packet if packets are arriving late", func() {
streamManager.EXPECT().CloseWithError(gomock.Any()) streamManager.EXPECT().CloseWithError(gomock.Any())
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{raw: []byte("foobar")}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{raw: []byte("foobar")}, nil)
sess.Close() sess.Close()
@ -504,7 +504,7 @@ var _ = Describe("Session", func() {
Expect(err).To(MatchError(testErr)) Expect(err).To(MatchError(testErr))
close(done) close(done)
}() }()
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
sess.handlePacket(&receivedPacket{header: hdr}) sess.handlePacket(&receivedPacket{header: hdr})
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
}) })
@ -735,7 +735,7 @@ var _ = Describe("Session", func() {
Consistently(mconn.written).Should(HaveLen(2)) Consistently(mconn.written).Should(HaveLen(2))
// make the go routine return // make the go routine return
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
sess.Close() sess.Close()
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
@ -762,7 +762,7 @@ var _ = Describe("Session", func() {
Consistently(mconn.written).Should(HaveLen(1)) Consistently(mconn.written).Should(HaveLen(1))
// make the go routine return // make the go routine return
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
sess.Close() sess.Close()
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
@ -791,7 +791,7 @@ var _ = Describe("Session", func() {
Eventually(mconn.written, 2*pacingDelay).Should(HaveLen(2)) Eventually(mconn.written, 2*pacingDelay).Should(HaveLen(2))
// make the go routine return // make the go routine return
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
sess.Close() sess.Close()
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
@ -817,7 +817,7 @@ var _ = Describe("Session", func() {
Eventually(mconn.written).Should(HaveLen(3)) Eventually(mconn.written).Should(HaveLen(3))
// make the go routine return // make the go routine return
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
sess.Close() sess.Close()
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
@ -838,7 +838,7 @@ var _ = Describe("Session", func() {
sess.scheduleSending() // no packet will get sent sess.scheduleSending() // no packet will get sent
Consistently(mconn.written).ShouldNot(Receive()) Consistently(mconn.written).ShouldNot(Receive())
// make the go routine return // make the go routine return
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
sess.Close() sess.Close()
@ -866,7 +866,7 @@ var _ = Describe("Session", func() {
sess.scheduleSending() sess.scheduleSending()
Eventually(mconn.written).Should(Receive()) Eventually(mconn.written).Should(Receive())
// make the go routine return // make the go routine return
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
streamManager.EXPECT().CloseWithError(gomock.Any()) streamManager.EXPECT().CloseWithError(gomock.Any())
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
@ -900,7 +900,7 @@ var _ = Describe("Session", func() {
Eventually(mconn.written).Should(Receive()) Eventually(mconn.written).Should(Receive())
// make sure the go routine returns // make sure the go routine returns
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
streamManager.EXPECT().CloseWithError(gomock.Any()) streamManager.EXPECT().CloseWithError(gomock.Any())
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
sess.Close() sess.Close()
@ -912,7 +912,7 @@ var _ = Describe("Session", func() {
It("closes when RunHandshake() errors", func() { It("closes when RunHandshake() errors", func() {
testErr := errors.New("crypto setup error") testErr := errors.New("crypto setup error")
streamManager.EXPECT().CloseWithError(qerr.Error(qerr.InternalError, testErr.Error())) streamManager.EXPECT().CloseWithError(qerr.Error(qerr.InternalError, testErr.Error()))
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
go func() { go func() {
@ -934,7 +934,7 @@ var _ = Describe("Session", func() {
}() }()
Consistently(sess.Context().Done()).ShouldNot(BeClosed()) Consistently(sess.Context().Done()).ShouldNot(BeClosed())
// make sure the go routine returns // make sure the go routine returns
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
streamManager.EXPECT().CloseWithError(gomock.Any()) streamManager.EXPECT().CloseWithError(gomock.Any())
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
@ -963,7 +963,7 @@ var _ = Describe("Session", func() {
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
//make sure the go routine returns //make sure the go routine returns
streamManager.EXPECT().CloseWithError(gomock.Any()) streamManager.EXPECT().CloseWithError(gomock.Any())
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
Expect(sess.Close()).To(Succeed()) Expect(sess.Close()).To(Succeed())
@ -979,7 +979,7 @@ var _ = Describe("Session", func() {
close(done) close(done)
}() }()
streamManager.EXPECT().CloseWithError(gomock.Any()) streamManager.EXPECT().CloseWithError(gomock.Any())
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
Expect(sess.Close()).To(Succeed()) Expect(sess.Close()).To(Succeed())
@ -997,7 +997,7 @@ var _ = Describe("Session", func() {
close(done) close(done)
}() }()
streamManager.EXPECT().CloseWithError(gomock.Any()) streamManager.EXPECT().CloseWithError(gomock.Any())
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
Expect(sess.CloseWithError(0x1337, testErr)).To(Succeed()) Expect(sess.CloseWithError(0x1337, testErr)).To(Succeed())
@ -1021,7 +1021,7 @@ var _ = Describe("Session", func() {
sess.processTransportParameters(params) sess.processTransportParameters(params)
// make the go routine return // make the go routine return
streamManager.EXPECT().CloseWithError(gomock.Any()) streamManager.EXPECT().CloseWithError(gomock.Any())
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
sess.Close() sess.Close()
@ -1055,7 +1055,7 @@ var _ = Describe("Session", func() {
}() }()
Eventually(sent).Should(BeClosed()) Eventually(sent).Should(BeClosed())
// make the go routine return // make the go routine return
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
streamManager.EXPECT().CloseWithError(gomock.Any()) streamManager.EXPECT().CloseWithError(gomock.Any())
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
@ -1076,7 +1076,7 @@ var _ = Describe("Session", func() {
}() }()
Consistently(mconn.written).ShouldNot(Receive()) Consistently(mconn.written).ShouldNot(Receive())
// make the go routine return // make the go routine return
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
streamManager.EXPECT().CloseWithError(gomock.Any()) streamManager.EXPECT().CloseWithError(gomock.Any())
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
@ -1097,7 +1097,7 @@ var _ = Describe("Session", func() {
}() }()
Consistently(mconn.written).ShouldNot(Receive()) Consistently(mconn.written).ShouldNot(Receive())
// make the go routine return // make the go routine return
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
streamManager.EXPECT().CloseWithError(gomock.Any()) streamManager.EXPECT().CloseWithError(gomock.Any())
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
@ -1112,7 +1112,7 @@ var _ = Describe("Session", func() {
}) })
It("times out due to no network activity", func() { It("times out due to no network activity", func() {
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
sess.handshakeComplete = true sess.handshakeComplete = true
sess.lastNetworkActivityTime = time.Now().Add(-time.Hour) sess.lastNetworkActivityTime = time.Now().Add(-time.Hour)
done := make(chan struct{}) done := make(chan struct{})
@ -1133,7 +1133,7 @@ var _ = Describe("Session", func() {
It("times out due to non-completed handshake", func() { It("times out due to non-completed handshake", func() {
sess.sessionCreationTime = time.Now().Add(-protocol.DefaultHandshakeTimeout).Add(-time.Second) sess.sessionCreationTime = time.Now().Add(-protocol.DefaultHandshakeTimeout).Add(-time.Second)
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
packer.EXPECT().PackConnectionClose(gomock.Any()).DoAndReturn(func(f *wire.ConnectionCloseFrame) (*packedPacket, error) { packer.EXPECT().PackConnectionClose(gomock.Any()).DoAndReturn(func(f *wire.ConnectionCloseFrame) (*packedPacket, error) {
Expect(f.ErrorCode).To(Equal(qerr.HandshakeTimeout)) Expect(f.ErrorCode).To(Equal(qerr.HandshakeTimeout))
@ -1166,7 +1166,7 @@ var _ = Describe("Session", func() {
}() }()
Consistently(sess.Context().Done()).ShouldNot(BeClosed()) Consistently(sess.Context().Done()).ShouldNot(BeClosed())
// make the go routine return // make the go routine return
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
sess.Close() sess.Close()
Eventually(sess.Context().Done()).Should(BeClosed()) Eventually(sess.Context().Done()).Should(BeClosed())
@ -1174,7 +1174,7 @@ var _ = Describe("Session", func() {
It("closes the session due to the idle timeout after handshake", func() { It("closes the session due to the idle timeout after handshake", func() {
packer.EXPECT().PackPacket().AnyTimes() packer.EXPECT().PackPacket().AnyTimes()
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
packer.EXPECT().PackConnectionClose(gomock.Any()).DoAndReturn(func(f *wire.ConnectionCloseFrame) (*packedPacket, error) { packer.EXPECT().PackConnectionClose(gomock.Any()).DoAndReturn(func(f *wire.ConnectionCloseFrame) (*packedPacket, error) {
Expect(f.ErrorCode).To(Equal(qerr.NetworkIdleTimeout)) Expect(f.ErrorCode).To(Equal(qerr.NetworkIdleTimeout))
@ -1348,7 +1348,7 @@ var _ = Describe("Client Session", func() {
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
// make sure the go routine returns // make sure the go routine returns
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil) packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
sessionRunner.EXPECT().removeConnectionID(gomock.Any()) sessionRunner.EXPECT().retireConnectionID(gomock.Any())
cryptoSetup.EXPECT().Close() cryptoSetup.EXPECT().Close()
Expect(sess.Close()).To(Succeed()) Expect(sess.Close()).To(Succeed())
Eventually(sess.Context().Done()).Should(BeClosed()) Eventually(sess.Context().Done()).Should(BeClosed())