mirror of
https://github.com/apple/swift-nio-http2
synced 2026-11-30 05:28:45 +00:00
Avoid double-counting of flow controlled length of synthesised data frames. (#114)
Motivation: When synthesising data frames we try to emit the flow controlled length of the entire real data frame on the first synthetic frame. This allows us to correctly police the window management of that frame, while still synthesising frames. However, @glbrntt spotted that we were incorrectly repeatedly counting the flow controlled length of a partial frame. A patch that had been previously added to ensure we only counted it once was not working correctly. Modifications: - Adjusted the location of the call to flowControlledLength. Result: Correct accounting of flow controlled length
This commit is contained in:
1 parent
144f9d2a0e
commit
6a97259a5d
3 files changed
+38
-1
No files matched your search
@@ -481,6 +481,11 @@ struct HTTP2FrameDecoder {
|
||||
var frameBytes: ByteBuffer
|
||||
var nextState: ParserState
|
||||
var flags: FrameFlags = state.header.flags
|
||||
|
||||
// We extract the flow controlled length early because we only ever emit it once for a given frame.
|
||||
// This operation mutates the flow controlled length and sets it to zero, so it will always give an appropriate result.
|
||||
let flowControlledLength = state.flowControlledLength()
|
||||
|
||||
if state.payload.readableBytes >= state.remainingByteCount {
|
||||
// read all the bytes for this last frame
|
||||
frameBytes = state.payload.readSlice(length: state.remainingByteCount - Int(state.expectedPadding))!
|
||||
@@ -510,7 +515,7 @@ struct HTTP2FrameDecoder {
|
||||
let dataPayload = HTTP2Frame.FramePayload.Data(data: .byteBuffer(frameBytes), endStream: flags.contains(.endStream), paddingBytes: nil)
|
||||
let outputFrame = HTTP2Frame(streamID: streamID, payload: .data(dataPayload))
|
||||
self.state = nextState
|
||||
return .frame(outputFrame, flowControlledLength: state.flowControlledLength())
|
||||
return .frame(outputFrame, flowControlledLength: flowControlledLength)
|
||||
|
||||
case .accumulatingContinuationPayload(var state):
|
||||
guard state.continuationHeader.length <= state.continuationPayload.readableBytes else {
|
||||
|
||||
Reference in new issue
Block a user