implement sending of MAX_STREAM_ID frames

We can now impose a limit on the number of stream for IETF QUIC, and
advertise that in the transport parameters during the handshake.
This commit is contained in:
Marten Seemann 2018-02-05 21:09:05 +08:00
parent e36b8d8e30
commit 8e332c2e13
11 changed files with 208 additions and 41 deletions

View file

@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"github.com/golang/mock/gomock"
"github.com/lucas-clemente/quic-go/internal/flowcontrol"
"github.com/lucas-clemente/quic-go/internal/handshake"
"github.com/lucas-clemente/quic-go/internal/mocks"
@ -50,7 +51,10 @@ var _ = Describe("Streams Map (for IETF QUIC)", func() {
}
Context(perspective.String(), func() {
var m *streamsMap
var (
m *streamsMap
mockSender *MockStreamSender
)
allowUnlimitedStreams := func() {
m.UpdateLimits(&handshake.TransportParameters{
@ -60,7 +64,8 @@ var _ = Describe("Streams Map (for IETF QUIC)", func() {
}
BeforeEach(func() {
m = newStreamsMap(nil, newFlowController, perspective, versionIETFFrames).(*streamsMap)
mockSender = NewMockStreamSender(mockCtrl)
m = newStreamsMap(mockSender, newFlowController, perspective, versionIETFFrames).(*streamsMap)
})
Context("opening", func() {
@ -111,6 +116,7 @@ var _ = Describe("Streams Map (for IETF QUIC)", func() {
Context("deleting", func() {
BeforeEach(func() {
mockSender.EXPECT().queueControlFrame(gomock.Any()).AnyTimes()
allowUnlimitedStreams()
})
@ -306,6 +312,26 @@ var _ = Describe("Streams Map (for IETF QUIC)", func() {
})
})
Context("sending MAX_STREAM_ID frames", func() {
It("sends MAX_STREAM_ID frames for bidirectional streams", func() {
_, err := m.GetOrOpenReceiveStream(ids.firstIncomingBidiStream + 4*10)
Expect(err).ToNot(HaveOccurred())
mockSender.EXPECT().queueControlFrame(&wire.MaxStreamIDFrame{
StreamID: protocol.MaxBidiStreamID(protocol.MaxIncomingStreams, perspective) + 4,
})
Expect(m.DeleteStream(ids.firstIncomingBidiStream)).To(Succeed())
})
It("sends MAX_STREAM_ID frames for unidirectional streams", func() {
_, err := m.GetOrOpenReceiveStream(ids.firstIncomingUniStream + 4*10)
Expect(err).ToNot(HaveOccurred())
mockSender.EXPECT().queueControlFrame(&wire.MaxStreamIDFrame{
StreamID: protocol.MaxUniStreamID(protocol.MaxIncomingStreams, perspective) + 4,
})
Expect(m.DeleteStream(ids.firstIncomingUniStream)).To(Succeed())
})
})
It("closes", func() {
testErr := errors.New("test error")
m.CloseWithError(testErr)