add DataLen function to StreamFrame

This commit is contained in:
Marten Seemann
2016-06-01 09:23:26 +07:00
parent 981d4e7fb8
commit 2f49a9525a
7 changed files with 38 additions and 24 deletions

View File

@@ -46,7 +46,7 @@ func (q *streamFrameQueue) Push(frame *frames.StreamFrame, prio bool) {
}
}
q.byteLen += protocol.ByteCount(len(frame.Data))
q.byteLen += frame.DataLen()
q.len++
}
@@ -99,7 +99,7 @@ func (q *streamFrameQueue) Pop(maxLength protocol.ByteCount) (*frames.StreamFram
splitFrame := q.maybeSplitOffFrame(frame, maxLength)
if splitFrame != nil { // StreamFrame was split
q.byteLen -= protocol.ByteCount(len(splitFrame.Data))
q.byteLen -= splitFrame.DataLen()
return splitFrame, nil
}
@@ -110,7 +110,7 @@ func (q *streamFrameQueue) Pop(maxLength protocol.ByteCount) (*frames.StreamFram
q.frameMap[streamID] = q.frameMap[streamID][1:]
}
q.byteLen -= protocol.ByteCount(len(frame.Data))
q.byteLen -= frame.DataLen()
q.len--
return frame, nil
}
@@ -144,7 +144,7 @@ func (q *streamFrameQueue) getNextStream() (protocol.StreamID, error) {
// has to be called from a function that has already acquired the mutex
func (q *streamFrameQueue) maybeSplitOffFrame(frame *frames.StreamFrame, n protocol.ByteCount) *frames.StreamFrame {
minLength, _ := frame.MinLength() // StreamFrame.MinLength *never* errors
if n >= minLength-1+protocol.ByteCount(len(frame.Data)) {
if n >= minLength-1+frame.DataLen() {
return nil
}
n -= minLength - 1