Skip to content

Commit

Permalink
Merge pull request #56 from libp2p/fix/initial-update
Browse files Browse the repository at this point in the history
fix: don't change the receive window if we're forcing an update
  • Loading branch information
Stebalien committed May 10, 2021
2 parents 6a03abf + 39a5ffd commit 391ef8d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 0 additions & 1 deletion session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,6 @@ func TestSession_PartialReadWindowUpdate(t *testing.T) {
sendWindow := atomic.LoadUint32(&wr.sendWindow)
if sendWindow != initialStreamWindow {
t.Errorf("sendWindow: exp=%d, got=%d", client.config.InitialStreamWindowSize, sendWindow)
return
}

n, err := wr.Write(make([]byte, flood))
Expand Down
3 changes: 2 additions & 1 deletion stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ func (s *Stream) sendWindowUpdate() error {
if !needed {
return nil
}

now := time.Now()
if rtt := s.session.getRTT(); rtt > 0 && now.Sub(s.epochStart) < rtt*4 {
if rtt := s.session.getRTT(); flags == 0 && rtt > 0 && now.Sub(s.epochStart) < rtt*4 {
var recvWindow uint32
if s.recvWindow > math.MaxUint32/2 {
recvWindow = min(math.MaxUint32, s.session.config.MaxStreamWindowSize)
Expand Down

0 comments on commit 391ef8d

Please sign in to comment.