diff --git a/internal/flowcontrol/base_flow_controller.go b/internal/flowcontrol/base_flow_controller.go index 616e4bf5c..d4e5c8a54 100644 --- a/internal/flowcontrol/base_flow_controller.go +++ b/internal/flowcontrol/base_flow_controller.go @@ -10,35 +10,28 @@ import ( ) type baseFlowController struct { - mutex sync.RWMutex - - rttStats *congestion.RTTStats - + // for sending data bytesSent protocol.ByteCount sendWindow protocol.ByteCount - lastWindowUpdateTime time.Time - + // for receiving data + mutex sync.RWMutex bytesRead protocol.ByteCount highestReceived protocol.ByteCount receiveWindow protocol.ByteCount receiveWindowIncrement protocol.ByteCount maxReceiveWindowIncrement protocol.ByteCount + lastWindowUpdateTime time.Time + rttStats *congestion.RTTStats } func (c *baseFlowController) AddBytesSent(n protocol.ByteCount) { - c.mutex.Lock() - defer c.mutex.Unlock() - c.bytesSent += n } // UpdateSendWindow should be called after receiving a WindowUpdateFrame // it returns true if the window was actually updated func (c *baseFlowController) UpdateSendWindow(offset protocol.ByteCount) { - c.mutex.Lock() - defer c.mutex.Unlock() - if offset > c.sendWindow { c.sendWindow = offset } @@ -82,9 +75,6 @@ func (c *baseFlowController) getWindowUpdate() protocol.ByteCount { // IsBlocked says if it is blocked by flow control. // If it is blocked, the offset is returned. func (c *baseFlowController) IsBlocked() (bool, protocol.ByteCount) { - c.mutex.RLock() - defer c.mutex.RUnlock() - if c.sendWindowSize() != 0 { return false, 0 } diff --git a/internal/flowcontrol/connection_flow_controller.go b/internal/flowcontrol/connection_flow_controller.go index 934d646de..1e1694770 100644 --- a/internal/flowcontrol/connection_flow_controller.go +++ b/internal/flowcontrol/connection_flow_controller.go @@ -34,9 +34,6 @@ func NewConnectionFlowController( } func (c *connectionFlowController) SendWindowSize() protocol.ByteCount { - c.mutex.RLock() - defer c.mutex.RUnlock() - return c.baseFlowController.sendWindowSize() } diff --git a/internal/flowcontrol/stream_flow_controller.go b/internal/flowcontrol/stream_flow_controller.go index dadba72e5..132df8272 100644 --- a/internal/flowcontrol/stream_flow_controller.go +++ b/internal/flowcontrol/stream_flow_controller.go @@ -102,9 +102,6 @@ func (c *streamFlowController) AddBytesSent(n protocol.ByteCount) { } func (c *streamFlowController) SendWindowSize() protocol.ByteCount { - c.mutex.Lock() - defer c.mutex.Unlock() - window := c.baseFlowController.sendWindowSize() if c.contributesToConnection { window = utils.MinByteCount(window, c.connection.SendWindowSize())