From 39a5ffd8e92981231b990fa9ce323ed6f4dfca9f Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 5 May 2021 14:13:14 -0700 Subject: [PATCH] fix: don't change the receive window if we're forcing an update Otherwise, our initial SYN/SYN-ACK packet will update the receive window every time. --- session_test.go | 1 - stream.go | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/session_test.go b/session_test.go index a6aed96..d6bcca3 100644 --- a/session_test.go +++ b/session_test.go @@ -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)) diff --git a/stream.go b/stream.go index 25f3036..2f95cc9 100644 --- a/stream.go +++ b/stream.go @@ -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)