forked from quic-go/quic-go
exit framer loop early if no space is left in packet
This commit is contained in:
@@ -125,6 +125,11 @@ func (f *streamFramer) maybePopNormalFrames(maxBytes protocol.ByteCount) (res []
|
|||||||
|
|
||||||
res = append(res, frame)
|
res = append(res, frame)
|
||||||
currentLen += frameHeaderBytes + frame.DataLen()
|
currentLen += frameHeaderBytes + frame.DataLen()
|
||||||
|
|
||||||
|
if currentLen == maxBytes {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
frame = &frames.StreamFrame{DataLenPresent: true}
|
frame = &frames.StreamFrame{DataLenPresent: true}
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,10 +140,10 @@ func (m *streamsMap) RoundRobinIterate(fn streamLambda) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
m.roundRobinIndex = (m.roundRobinIndex + 1) % numStreams
|
||||||
if !cont {
|
if !cont {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
m.roundRobinIndex = (m.roundRobinIndex + 1) % numStreams
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -321,7 +321,7 @@ var _ = Describe("Streams Map", func() {
|
|||||||
Expect(m.roundRobinIndex).To(Equal(3))
|
Expect(m.roundRobinIndex).To(Equal(3))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("picks up at the index where it last stopped", func() {
|
It("picks up at the index+1 where it last stopped", func() {
|
||||||
fn := func(str *stream) (bool, error) {
|
fn := func(str *stream) (bool, error) {
|
||||||
lambdaCalledForStream = append(lambdaCalledForStream, str.StreamID())
|
lambdaCalledForStream = append(lambdaCalledForStream, str.StreamID())
|
||||||
numIterations++
|
numIterations++
|
||||||
@@ -334,7 +334,7 @@ var _ = Describe("Streams Map", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(numIterations).To(Equal(2))
|
Expect(numIterations).To(Equal(2))
|
||||||
Expect(lambdaCalledForStream).To(Equal([]protocol.StreamID{4, 5}))
|
Expect(lambdaCalledForStream).To(Equal([]protocol.StreamID{4, 5}))
|
||||||
Expect(m.roundRobinIndex).To(Equal(1))
|
Expect(m.roundRobinIndex).To(Equal(2))
|
||||||
numIterations = 0
|
numIterations = 0
|
||||||
lambdaCalledForStream = lambdaCalledForStream[:0]
|
lambdaCalledForStream = lambdaCalledForStream[:0]
|
||||||
fn2 := func(str *stream) (bool, error) {
|
fn2 := func(str *stream) (bool, error) {
|
||||||
@@ -347,8 +347,8 @@ var _ = Describe("Streams Map", func() {
|
|||||||
}
|
}
|
||||||
err = m.RoundRobinIterate(fn2)
|
err = m.RoundRobinIterate(fn2)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(numIterations).To(Equal(3))
|
Expect(numIterations).To(Equal(2))
|
||||||
Expect(lambdaCalledForStream).To(Equal([]protocol.StreamID{5, 6, 7}))
|
Expect(lambdaCalledForStream).To(Equal([]protocol.StreamID{6, 7}))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("adjust the RoundRobinIndex when deleting an element in front", func() {
|
It("adjust the RoundRobinIndex when deleting an element in front", func() {
|
||||||
|
|||||||
Reference in New Issue
Block a user