mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 04:07:35 +03:00
queue connection-level window updates from the flow controller directly
It is not sufficient to check for connection-level window updates every time a packet is sent. When a connection-level window update needs to be sent, we need to make sure that it gets sent immediately (i.e. call scheduleSending() in the session).
This commit is contained in:
parent
2e8a5807ba
commit
08160ab18f
10 changed files with 126 additions and 55 deletions
|
@ -1,6 +1,7 @@
|
|||
package quic
|
||||
|
||||
import (
|
||||
"github.com/lucas-clemente/quic-go/internal/mocks"
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||
|
||||
|
@ -12,6 +13,7 @@ var _ = Describe("Window Update Queue", func() {
|
|||
var (
|
||||
q *windowUpdateQueue
|
||||
streamGetter *MockStreamGetter
|
||||
connFC *mocks.MockConnectionFlowController
|
||||
queuedFrames []wire.Frame
|
||||
cryptoStream *MockCryptoStream
|
||||
)
|
||||
|
@ -19,9 +21,10 @@ var _ = Describe("Window Update Queue", func() {
|
|||
BeforeEach(func() {
|
||||
streamGetter = NewMockStreamGetter(mockCtrl)
|
||||
cryptoStream = NewMockCryptoStream(mockCtrl)
|
||||
connFC = mocks.NewMockConnectionFlowController(mockCtrl)
|
||||
cryptoStream.EXPECT().StreamID().Return(protocol.StreamID(0)).AnyTimes()
|
||||
queuedFrames = queuedFrames[:0]
|
||||
q = newWindowUpdateQueue(streamGetter, cryptoStream, func(f wire.Frame) {
|
||||
q = newWindowUpdateQueue(streamGetter, cryptoStream, connFC, func(f wire.Frame) {
|
||||
queuedFrames = append(queuedFrames, f)
|
||||
})
|
||||
})
|
||||
|
@ -33,8 +36,8 @@ var _ = Describe("Window Update Queue", func() {
|
|||
stream3.EXPECT().getWindowUpdate().Return(protocol.ByteCount(30))
|
||||
streamGetter.EXPECT().GetOrOpenReceiveStream(protocol.StreamID(3)).Return(stream3, nil)
|
||||
streamGetter.EXPECT().GetOrOpenReceiveStream(protocol.StreamID(1)).Return(stream1, nil)
|
||||
q.Add(3)
|
||||
q.Add(1)
|
||||
q.AddStream(3)
|
||||
q.AddStream(1)
|
||||
q.QueueAll()
|
||||
Expect(queuedFrames).To(ContainElement(&wire.MaxStreamDataFrame{StreamID: 1, ByteOffset: 10}))
|
||||
Expect(queuedFrames).To(ContainElement(&wire.MaxStreamDataFrame{StreamID: 3, ByteOffset: 30}))
|
||||
|
@ -44,7 +47,7 @@ var _ = Describe("Window Update Queue", func() {
|
|||
stream10 := NewMockStreamI(mockCtrl)
|
||||
stream10.EXPECT().getWindowUpdate().Return(protocol.ByteCount(100))
|
||||
streamGetter.EXPECT().GetOrOpenReceiveStream(protocol.StreamID(10)).Return(stream10, nil)
|
||||
q.Add(10)
|
||||
q.AddStream(10)
|
||||
q.QueueAll()
|
||||
Expect(queuedFrames).To(HaveLen(1))
|
||||
q.QueueAll()
|
||||
|
@ -53,7 +56,7 @@ var _ = Describe("Window Update Queue", func() {
|
|||
|
||||
It("doesn't queue a MAX_STREAM_DATA for a closed stream", func() {
|
||||
streamGetter.EXPECT().GetOrOpenReceiveStream(protocol.StreamID(12)).Return(nil, nil)
|
||||
q.Add(12)
|
||||
q.AddStream(12)
|
||||
q.QueueAll()
|
||||
Expect(queuedFrames).To(BeEmpty())
|
||||
})
|
||||
|
@ -62,26 +65,35 @@ var _ = Describe("Window Update Queue", func() {
|
|||
stream5 := NewMockStreamI(mockCtrl)
|
||||
stream5.EXPECT().getWindowUpdate().Return(protocol.ByteCount(0))
|
||||
streamGetter.EXPECT().GetOrOpenReceiveStream(protocol.StreamID(5)).Return(stream5, nil)
|
||||
q.Add(5)
|
||||
q.AddStream(5)
|
||||
q.QueueAll()
|
||||
Expect(queuedFrames).To(BeEmpty())
|
||||
})
|
||||
|
||||
It("adds MAX_STREAM_DATA frames for the crypto stream", func() {
|
||||
cryptoStream.EXPECT().getWindowUpdate().Return(protocol.ByteCount(42))
|
||||
q.Add(0)
|
||||
q.AddStream(0)
|
||||
q.QueueAll()
|
||||
Expect(queuedFrames).To(Equal([]wire.Frame{
|
||||
&wire.MaxStreamDataFrame{StreamID: 0, ByteOffset: 42},
|
||||
}))
|
||||
})
|
||||
|
||||
It("queues MAX_DATA frames", func() {
|
||||
connFC.EXPECT().GetWindowUpdate().Return(protocol.ByteCount(0x1337))
|
||||
q.AddConnection()
|
||||
q.QueueAll()
|
||||
Expect(queuedFrames).To(Equal([]wire.Frame{
|
||||
&wire.MaxDataFrame{ByteOffset: 0x1337},
|
||||
}))
|
||||
})
|
||||
|
||||
It("deduplicates", func() {
|
||||
stream10 := NewMockStreamI(mockCtrl)
|
||||
stream10.EXPECT().getWindowUpdate().Return(protocol.ByteCount(200))
|
||||
streamGetter.EXPECT().GetOrOpenReceiveStream(protocol.StreamID(10)).Return(stream10, nil)
|
||||
q.Add(10)
|
||||
q.Add(10)
|
||||
q.AddStream(10)
|
||||
q.AddStream(10)
|
||||
q.QueueAll()
|
||||
Expect(queuedFrames).To(Equal([]wire.Frame{
|
||||
&wire.MaxStreamDataFrame{StreamID: 10, ByteOffset: 200},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue