fix calculation of idle timeout when the peer sets max_idle_timeout to 0 (#4666)

This commit is contained in:
Marten Seemann
2024-09-08 17:29:09 +08:00
committed by GitHub
parent 1ad36eb7b8
commit 8fc04bf1e0

View File

@@ -1768,8 +1768,9 @@ func (s *connection) applyTransportParameters() {
params := s.peerParams params := s.peerParams
// Our local idle timeout will always be > 0. // Our local idle timeout will always be > 0.
s.idleTimeout = s.config.MaxIdleTimeout s.idleTimeout = s.config.MaxIdleTimeout
if s.idleTimeout > 0 && params.MaxIdleTimeout < s.idleTimeout { // If the peer advertised an idle timeout, take the minimum of the values.
s.idleTimeout = params.MaxIdleTimeout if params.MaxIdleTimeout > 0 {
s.idleTimeout = min(s.idleTimeout, params.MaxIdleTimeout)
} }
s.keepAliveInterval = min(s.config.KeepAlivePeriod, min(s.idleTimeout/2, protocol.MaxKeepAliveInterval)) s.keepAliveInterval = min(s.config.KeepAlivePeriod, min(s.idleTimeout/2, protocol.MaxKeepAliveInterval))
s.streamsMap.UpdateLimits(params) s.streamsMap.UpdateLimits(params)