don't generate empty STREAM frames in the send stream (#4812)

This commit is contained in:
Marten Seemann
2024-12-28 16:21:48 +08:00
committed by GitHub
parent 55687a684f
commit 810ef27db5
2 changed files with 11 additions and 7 deletions

View File

@@ -277,6 +277,9 @@ func (s *sendStream) popNewOrRetransmittedStreamFrame(maxBytes protocol.ByteCoun
}
f, hasMoreData := s.popNewStreamFrame(maxBytes, sendWindow, v)
if f == nil {
return nil, hasMoreData, false
}
if dataLen := f.DataLen(); dataLen > 0 {
s.writeOffset += f.DataLen()
s.flowController.AddBytesSent(f.DataLen())
@@ -290,10 +293,12 @@ func (s *sendStream) popNewOrRetransmittedStreamFrame(maxBytes protocol.ByteCoun
func (s *sendStream) popNewStreamFrame(maxBytes, sendWindow protocol.ByteCount, v protocol.Version) (*wire.StreamFrame, bool) {
if s.nextFrame != nil {
maxDataLen := min(sendWindow, s.nextFrame.MaxDataLen(maxBytes, v))
if maxDataLen == 0 {
return nil, true
}
nextFrame := s.nextFrame
s.nextFrame = nil
maxDataLen := min(sendWindow, nextFrame.MaxDataLen(maxBytes, v))
if nextFrame.DataLen() > maxDataLen {
s.nextFrame = wire.GetStreamFrame()
s.nextFrame.StreamID = s.streamID