remove flow control mutexes for the sending data

Receiving MAX_{STREAM}_DATA frames and sending data is all done
sequentially, so we don't need a mutex there.
This commit is contained in:
Marten Seemann 2017-12-15 19:29:44 +07:00
parent efa781b067
commit bfdeeae70c
3 changed files with 5 additions and 21 deletions

View file

@ -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
}