Merge pull request #1037 from lucas-clemente/flow-control-mutexes

remove flow control mutexes for the sending data
This commit is contained in:
Marten Seemann
2017-12-16 08:57:59 +07:00
committed by GitHub
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
}

View File

@@ -34,9 +34,6 @@ func NewConnectionFlowController(
}
func (c *connectionFlowController) SendWindowSize() protocol.ByteCount {
c.mutex.RLock()
defer c.mutex.RUnlock()
return c.baseFlowController.sendWindowSize()
}

View File

@@ -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())