Skip to content

Commit

Permalink
Merge pull request #3692 from Lawo-Ext/main
Browse files Browse the repository at this point in the history
Fix for #3682 (Take 2): do not delay PINGs for GATEWAY or spoke LEAF connections
  • Loading branch information
derekcollison authored Dec 7, 2022
2 parents 5baf902 + 7907950 commit effccfd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions server/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4547,19 +4547,20 @@ func (c *client) processPingTimer() {

var sendPing bool

// If we have had activity within the PingInterval then
// there is no need to send a ping. This can be client data
// or if we received a ping from the other side.
pingInterval := c.srv.getOpts().PingInterval
if c.kind == GATEWAY {
pingInterval = adjustPingIntervalForGateway(pingInterval)
sendPing = true
}
now := time.Now()
needRTT := c.rtt == 0 || now.Sub(c.rttStart) > DEFAULT_RTT_MEASUREMENT_INTERVAL

// Do not delay PINGs for GATEWAY connections.
if c.kind != GATEWAY {
// Do not delay PINGs for GATEWAY or spoke LEAF connections.
if c.kind == GATEWAY || c.isSpokeLeafNode() {
sendPing = true
} else {
// If we have had activity within the PingInterval then
// there is no need to send a ping. This can be client data
// or if we received a ping from the other side.
if delta := now.Sub(c.last); delta < pingInterval && !needRTT {
c.Debugf("Delaying PING due to client activity %v ago", delta.Round(time.Second))
} else if delta := now.Sub(c.ping.last); delta < pingInterval && !needRTT {
Expand All @@ -4568,6 +4569,7 @@ func (c *client) processPingTimer() {
sendPing = true
}
}

if sendPing {
// Check for violation
if c.ping.out+1 > c.srv.getOpts().MaxPingsOut {
Expand Down

0 comments on commit effccfd

Please sign in to comment.