Merge pull request #1802 from lucas-clemente/timeout-errors

don't send timeout errors on the wire
This commit is contained in:
Marten Seemann
2019-03-05 18:06:00 +09:00
committed by GitHub
2 changed files with 5 additions and 17 deletions

View File

@@ -410,11 +410,11 @@ runLoop:
}
if !s.handshakeComplete && now.Sub(s.sessionCreationTime) >= s.config.HandshakeTimeout {
s.closeLocal(qerr.Error(qerr.HandshakeTimeout, "Crypto handshake did not complete in time."))
s.destroy(qerr.Error(qerr.HandshakeTimeout, "Crypto handshake did not complete in time."))
continue
}
if s.handshakeComplete && now.Sub(s.lastNetworkActivityTime) >= s.config.IdleTimeout {
s.closeLocal(qerr.Error(qerr.NetworkIdleTimeout, "No recent network activity."))
s.destroy(qerr.Error(qerr.NetworkIdleTimeout, "No recent network activity."))
continue
}

View File

@@ -1305,15 +1305,11 @@ var _ = Describe("Session", func() {
})
It("times out due to no network activity", func() {
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
sessionRunner.EXPECT().removeConnectionID(gomock.Any())
sess.handshakeComplete = true
sess.lastNetworkActivityTime = time.Now().Add(-time.Hour)
done := make(chan struct{})
cryptoSetup.EXPECT().Close()
packer.EXPECT().PackConnectionClose(gomock.Any()).DoAndReturn(func(f *wire.ConnectionCloseFrame) (*packedPacket, error) {
Expect(f.ErrorCode).To(Equal(qerr.NetworkIdleTimeout))
return &packedPacket{}, nil
})
go func() {
defer GinkgoRecover()
cryptoSetup.EXPECT().RunHandshake().Do(func() { <-sess.Context().Done() })
@@ -1326,12 +1322,8 @@ 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().retireConnectionID(gomock.Any())
sessionRunner.EXPECT().removeConnectionID(gomock.Any())
cryptoSetup.EXPECT().Close()
packer.EXPECT().PackConnectionClose(gomock.Any()).DoAndReturn(func(f *wire.ConnectionCloseFrame) (*packedPacket, error) {
Expect(f.ErrorCode).To(Equal(qerr.HandshakeTimeout))
return &packedPacket{}, nil
})
done := make(chan struct{})
go func() {
defer GinkgoRecover()
@@ -1367,12 +1359,8 @@ var _ = Describe("Session", func() {
It("closes the session due to the idle timeout after handshake", func() {
packer.EXPECT().PackPacket().AnyTimes()
sessionRunner.EXPECT().retireConnectionID(gomock.Any())
sessionRunner.EXPECT().removeConnectionID(gomock.Any())
cryptoSetup.EXPECT().Close()
packer.EXPECT().PackConnectionClose(gomock.Any()).DoAndReturn(func(f *wire.ConnectionCloseFrame) (*packedPacket, error) {
Expect(f.ErrorCode).To(Equal(qerr.NetworkIdleTimeout))
return &packedPacket{}, nil
})
sess.config.IdleTimeout = 0
done := make(chan struct{})
go func() {