mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
parent
d23df8addd
commit
f1da2239ca
3 changed files with 33 additions and 2 deletions
|
@ -191,7 +191,8 @@ func (f *StreamFrame) getOffsetLength() protocol.ByteCount {
|
|||
return 8
|
||||
}
|
||||
|
||||
// MinLength of a written frame
|
||||
// MinLength returns the length of the header of a StreamFrame
|
||||
// the total length of the StreamFrame is frame.MinLength() + frame.DataLen()
|
||||
func (f *StreamFrame) MinLength(protocol.VersionNumber) (protocol.ByteCount, error) {
|
||||
length := protocol.ByteCount(1) + protocol.ByteCount(f.calculateStreamIDLength()) + f.getOffsetLength()
|
||||
if f.DataLenPresent {
|
||||
|
|
|
@ -48,7 +48,7 @@ func (f *streamFramer) maybePopFramesForRetransmission(maxLen protocol.ByteCount
|
|||
frame.DataLenPresent = true
|
||||
|
||||
frameHeaderLen, _ := frame.MinLength(protocol.VersionWhatever) // can never error
|
||||
if currentLen+frameHeaderLen > maxLen {
|
||||
if currentLen+frameHeaderLen >= maxLen {
|
||||
break
|
||||
}
|
||||
|
||||
|
|
|
@ -175,6 +175,36 @@ var _ = Describe("Stream Framer", func() {
|
|||
Expect(framer.retransmissionQueue[0].Offset).To(Equal(fs[0].DataLen()))
|
||||
})
|
||||
|
||||
It("never returns an empty stream frame", func() {
|
||||
// this one frame will be split off from again and again in this test. Therefore, it has to be large enough (checked again at the end)
|
||||
origFrame := &frames.StreamFrame{
|
||||
StreamID: 5,
|
||||
Offset: 1,
|
||||
FinBit: false,
|
||||
Data: bytes.Repeat([]byte{'f'}, 30*30),
|
||||
}
|
||||
framer.AddFrameForRetransmission(origFrame)
|
||||
|
||||
minFrameDataLen := protocol.MaxFrameAndPublicHeaderSize
|
||||
|
||||
for i := 0; i < 30; i++ {
|
||||
frames, currentLen := framer.maybePopFramesForRetransmission(protocol.ByteCount(i))
|
||||
if len(frames) == 0 {
|
||||
Expect(currentLen).To(BeZero())
|
||||
} else {
|
||||
Expect(frames).To(HaveLen(1))
|
||||
Expect(currentLen).ToNot(BeZero())
|
||||
dataLen := frames[0].DataLen()
|
||||
Expect(dataLen).ToNot(BeZero())
|
||||
if dataLen < minFrameDataLen {
|
||||
minFrameDataLen = dataLen
|
||||
}
|
||||
}
|
||||
}
|
||||
Expect(framer.retransmissionQueue).To(HaveLen(1)) // check that origFrame was large enough for this test and didn't get used up completely
|
||||
Expect(minFrameDataLen).To(Equal(protocol.ByteCount(1)))
|
||||
})
|
||||
|
||||
It("only removes a frame from the framer after returning all split parts", func() {
|
||||
framer.AddFrameForRetransmission(retransmittedFrame2)
|
||||
fs := framer.PopStreamFrames(6)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue