forked from quic-go/quic-go
don't defer unlocking the mutex when getting window updates
This commit is contained in:
@@ -54,13 +54,12 @@ func (c *connectionFlowController) IncrementHighestReceived(increment protocol.B
|
|||||||
|
|
||||||
func (c *connectionFlowController) GetWindowUpdate() protocol.ByteCount {
|
func (c *connectionFlowController) GetWindowUpdate() protocol.ByteCount {
|
||||||
c.mutex.Lock()
|
c.mutex.Lock()
|
||||||
defer c.mutex.Unlock()
|
|
||||||
|
|
||||||
oldWindowIncrement := c.receiveWindowIncrement
|
oldWindowIncrement := c.receiveWindowIncrement
|
||||||
offset := c.baseFlowController.getWindowUpdate()
|
offset := c.baseFlowController.getWindowUpdate()
|
||||||
if oldWindowIncrement < c.receiveWindowIncrement {
|
if oldWindowIncrement < c.receiveWindowIncrement {
|
||||||
utils.Debugf("Increasing receive flow control window for the connection to %d kB", c.receiveWindowIncrement/(1<<10))
|
utils.Debugf("Increasing receive flow control window for the connection to %d kB", c.receiveWindowIncrement/(1<<10))
|
||||||
}
|
}
|
||||||
|
c.mutex.Unlock()
|
||||||
return offset
|
return offset
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,10 +67,9 @@ func (c *connectionFlowController) GetWindowUpdate() protocol.ByteCount {
|
|||||||
// it should make sure that the connection-level window is increased when a stream-level window grows
|
// it should make sure that the connection-level window is increased when a stream-level window grows
|
||||||
func (c *connectionFlowController) EnsureMinimumWindowIncrement(inc protocol.ByteCount) {
|
func (c *connectionFlowController) EnsureMinimumWindowIncrement(inc protocol.ByteCount) {
|
||||||
c.mutex.Lock()
|
c.mutex.Lock()
|
||||||
defer c.mutex.Unlock()
|
|
||||||
|
|
||||||
if inc > c.receiveWindowIncrement {
|
if inc > c.receiveWindowIncrement {
|
||||||
c.receiveWindowIncrement = utils.MinByteCount(inc, c.maxReceiveWindowIncrement)
|
c.receiveWindowIncrement = utils.MinByteCount(inc, c.maxReceiveWindowIncrement)
|
||||||
c.lastWindowUpdateTime = time.Time{} // disables autotuning for the next window update
|
c.lastWindowUpdateTime = time.Time{} // disables autotuning for the next window update
|
||||||
}
|
}
|
||||||
|
c.mutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,11 +113,11 @@ func (c *streamFlowController) SendWindowSize() protocol.ByteCount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *streamFlowController) GetWindowUpdate() protocol.ByteCount {
|
func (c *streamFlowController) GetWindowUpdate() protocol.ByteCount {
|
||||||
|
// don't use defer for unlocking the mutex here, GetWindowUpdate() is called frequently and defer shows up in the profiler
|
||||||
c.mutex.Lock()
|
c.mutex.Lock()
|
||||||
defer c.mutex.Unlock()
|
|
||||||
|
|
||||||
// if we already received the final offset for this stream, the peer won't need any additional flow control credit
|
// if we already received the final offset for this stream, the peer won't need any additional flow control credit
|
||||||
if c.receivedFinalOffset {
|
if c.receivedFinalOffset {
|
||||||
|
c.mutex.Unlock()
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,5 +129,6 @@ func (c *streamFlowController) GetWindowUpdate() protocol.ByteCount {
|
|||||||
c.connection.EnsureMinimumWindowIncrement(protocol.ByteCount(float64(c.receiveWindowIncrement) * protocol.ConnectionFlowControlMultiplier))
|
c.connection.EnsureMinimumWindowIncrement(protocol.ByteCount(float64(c.receiveWindowIncrement) * protocol.ConnectionFlowControlMultiplier))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
c.mutex.Unlock()
|
||||||
return offset
|
return offset
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user