Updates from comments

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2019-07-01 08:47:13 -07:00
parent ebd4deb8b9
commit 8a3db71ad5
2 changed files with 4 additions and 3 deletions

View File

@@ -1463,7 +1463,7 @@ func (c *client) processPing() {
c.sendPong()
// Record this to suppress us sending one if this
// is withing a given time interval for activity.
// is within a given time interval for activity.
c.ping.last = time.Now()
// If not a CLIENT, we are done
@@ -2666,7 +2666,7 @@ func (c *client) processPingTimer() {
}
// Lock should be held
// We Randomize the first one by an offset up to 20%, e.g. 2m ~= max 24s.
// We randomize the first one by an offset up to 20%, e.g. 2m ~= max 24s.
// This is because the clients by default are usually setting same interval
// and we have alot of cross ping/pongs between clients and servers.
// We will now suppress the server ping/pong if we have received a client ping.

View File

@@ -223,6 +223,7 @@ func TestPingSuppresion(t *testing.T) {
send("PING\r\n")
expect(pongRe)
// This will wait for
// This will wait for the time period where a PING should have fired
// and been delivered. We expect nothing here since it should be suppressed.
expectNothingTimeout(t, c, time.Now().Add(100*time.Millisecond))
}