don't defer unlocking the mutex when getting window updates

This commit is contained in:
Marten Seemann
2017-12-15 19:49:41 +07:00
parent efa781b067
commit 357a2f6213
2 changed files with 5 additions and 6 deletions

View File

@@ -113,11 +113,11 @@ func (c *streamFlowController) SendWindowSize() 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()
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 c.receivedFinalOffset {
c.mutex.Unlock()
return 0
}
@@ -129,5 +129,6 @@ func (c *streamFlowController) GetWindowUpdate() protocol.ByteCount {
c.connection.EnsureMinimumWindowIncrement(protocol.ByteCount(float64(c.receiveWindowIncrement) * protocol.ConnectionFlowControlMultiplier))
}
}
c.mutex.Unlock()
return offset
}