diff --git a/flowcontrol/flow_control_manager.go b/flowcontrol/flow_control_manager.go index 5c8d5b7d..9362d60a 100644 --- a/flowcontrol/flow_control_manager.go +++ b/flowcontrol/flow_control_manager.go @@ -78,7 +78,7 @@ func (f *flowControlManager) ResetStream(streamID protocol.StreamID, byteOffset if streamFlowController.ContributesToConnection() { f.connFlowController.IncrementHighestReceived(increment) if f.connFlowController.CheckFlowControlViolation() { - return qerr.Error(qerr.FlowControlReceivedTooMuchData, fmt.Sprintf("Received %d bytes for the connection, allowed %d bytes", byteOffset, f.connFlowController.receiveWindow)) + return qerr.Error(qerr.FlowControlReceivedTooMuchData, fmt.Sprintf("Received %d bytes for the connection, allowed %d bytes", f.connFlowController.highestReceived, f.connFlowController.receiveWindow)) } } @@ -107,7 +107,7 @@ func (f *flowControlManager) UpdateHighestReceived(streamID protocol.StreamID, b if streamFlowController.ContributesToConnection() { f.connFlowController.IncrementHighestReceived(increment) if f.connFlowController.CheckFlowControlViolation() { - return qerr.Error(qerr.FlowControlReceivedTooMuchData, fmt.Sprintf("Received %d bytes for the connection, allowed %d bytes", byteOffset, f.connFlowController.receiveWindow)) + return qerr.Error(qerr.FlowControlReceivedTooMuchData, fmt.Sprintf("Received %d bytes for the connection, allowed %d bytes", f.connFlowController.highestReceived, f.connFlowController.receiveWindow)) } } diff --git a/flowcontrol/flow_control_manager_test.go b/flowcontrol/flow_control_manager_test.go index df1622dd..4911167f 100644 --- a/flowcontrol/flow_control_manager_test.go +++ b/flowcontrol/flow_control_manager_test.go @@ -115,8 +115,11 @@ var _ = Describe("Flow Control Manager", func() { It("errors when encountering a connection-level flow control violation", func() { fcm.streamFlowController[4].receiveWindow = 300 - err := fcm.UpdateHighestReceived(4, 201) - Expect(err).To(MatchError(qerr.Error(qerr.FlowControlReceivedTooMuchData, "Received 201 bytes for the connection, allowed 200 bytes"))) + fcm.streamFlowController[6].receiveWindow = 300 + err := fcm.UpdateHighestReceived(6, 100) + Expect(err).ToNot(HaveOccurred()) + err = fcm.UpdateHighestReceived(4, 103) + Expect(err).To(MatchError(qerr.Error(qerr.FlowControlReceivedTooMuchData, "Received 203 bytes for the connection, allowed 200 bytes"))) }) }) @@ -230,7 +233,10 @@ var _ = Describe("Flow Control Manager", func() { It("errors when encountering a connection-level flow control violation", func() { fcm.streamFlowController[4].receiveWindow = 300 - err := fcm.ResetStream(4, 201) + fcm.streamFlowController[6].receiveWindow = 300 + err := fcm.ResetStream(4, 100) + Expect(err).ToNot(HaveOccurred()) + err = fcm.ResetStream(6, 101) Expect(err).To(MatchError(qerr.Error(qerr.FlowControlReceivedTooMuchData, "Received 201 bytes for the connection, allowed 200 bytes"))) }) })