Skip to content

Commit

Permalink
fix: don't change the receive window if we're forcing an update
Browse files Browse the repository at this point in the history
Otherwise, our initial SYN/SYN-ACK packet will update the receive window
every time.
  • Loading branch information
Stebalien committed May 5, 2021
1 parent 6a03abf commit 39a5ffd
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 39a5ffd

Please sign in to comment.