don't send write error in CONNECTION_CLOSE frames

This commit is contained in:
Marten Seemann 2020-07-09 18:09:20 +07:00
parent 953f3472cf
commit 61d8e111b1
2 changed files with 29 additions and 1 deletions

View file

@ -517,7 +517,7 @@ func (s *session) run() error {
go s.cryptoStreamHandler.RunHandshake()
go func() {
if err := s.sendQueue.Run(); err != nil {
s.closeLocal(err)
s.destroyImpl(err)
}
}()

View file

@ -7,6 +7,7 @@ import (
"crypto/tls"
"errors"
"fmt"
"io"
"net"
"runtime/pprof"
"strings"
@ -559,6 +560,33 @@ var _ = Describe("Session", func() {
// Consistently(pack).ShouldNot(Receive())
Eventually(sess.Context().Done()).Should(BeClosed())
})
It("closes when the sendQueue encounters an error", func() {
sess.handshakeConfirmed = true
conn := NewMockConnection(mockCtrl)
conn.EXPECT().Write(gomock.Any()).Return(io.ErrClosedPipe).AnyTimes()
sess.sendQueue = newSendQueue(conn)
sph := mockackhandler.NewMockSentPacketHandler(mockCtrl)
sph.EXPECT().GetLossDetectionTimeout().Return(time.Now().Add(time.Hour)).AnyTimes()
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
sph.EXPECT().HasPacingBudget().Return(true).AnyTimes()
sph.EXPECT().AmplificationWindow().Return(protocol.MaxByteCount).AnyTimes()
// only expect a single SentPacket() call
sph.EXPECT().SentPacket(gomock.Any())
tracer.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
tracer.EXPECT().Close()
streamManager.EXPECT().CloseWithError(gomock.Any())
sessionRunner.EXPECT().Remove(gomock.Any()).AnyTimes()
cryptoSetup.EXPECT().Close()
sess.sentPacketHandler = sph
p := getPacket(1)
packer.EXPECT().PackPacket().Return(p, nil)
packer.EXPECT().PackPacket().Return(nil, nil).AnyTimes()
runSession()
sess.queueControlFrame(&wire.PingFrame{})
sess.scheduleSending()
Eventually(sess.Context().Done()).Should(BeClosed())
})
})
Context("receiving packets", func() {