@@ -411,21 +411,22 @@ func (g *GoBackNConn) sendPacketsForever() error {
411411 continue
412412
413413 case <- g .pingTicker .Ticks ():
414- // If we have expected a sync after sending the previous
415- // ping, both the pingTicker and pongTicker may have
416- // ticked when waiting to sync. In that case, we can't
417- // be sure which of the signals we receive over first in
418- // the above select. We therefore need to check if the
419- // pong ticker has ticked here to ensure that it get's
420- // prioritized over the ping ticker.
414+ // The pong timeout is capped at the ping interval, so
415+ // if we're still waiting for a response to the previous
416+ // ping then both tickers may fire at roughly the same
417+ // time. In that case the keepalive timeout must win
418+ // over sending a new ping.
421419 select {
422420 case <- g .pongTicker .Ticks ():
423421 return errKeepaliveTimeout
424422 default :
425423 }
426424
427- // Start the pong timer.
428- g .pongTicker .Reset ()
425+ // Start the pong timer. We use ResetWithInterval
426+ // to pick up any dynamic pong timeout changes
427+ // based on observed RTT.
428+ pongTime := g .timeoutManager .GetPongTime ()
429+ g .pongTicker .ResetWithInterval (pongTime )
429430 g .pongTicker .Resume ()
430431
431432 // Also reset the ping timer.
0 commit comments