avoid duplicate mutex locking when reading data

This commit is contained in:
Marten Seemann
2020-11-09 09:15:21 +07:00
parent 5352cd509b
commit 655632b116
5 changed files with 22 additions and 30 deletions

View File

@@ -55,15 +55,11 @@ func (c *connectionFlowController) IncrementHighestReceived(increment protocol.B
}
func (c *connectionFlowController) AddBytesRead(n protocol.ByteCount) {
c.baseFlowController.AddBytesRead(n)
c.maybeQueueWindowUpdate()
}
func (c *connectionFlowController) maybeQueueWindowUpdate() {
c.mutex.Lock()
hasWindowUpdate := c.hasWindowUpdate()
c.baseFlowController.addBytesRead(n)
shouldQueueWindowUpdate := c.hasWindowUpdate()
c.mutex.Unlock()
if hasWindowUpdate {
if shouldQueueWindowUpdate {
c.queueWindowUpdate()
}
}