From 2a938d96aec62603dcb548834676ae2c71ae8be2 Mon Sep 17 00:00:00 2001 From: Pedro Calado Date: Thu, 29 Oct 2020 14:20:38 +0000 Subject: [PATCH] fix(server): reschedule keep alive interval timer once a pong is received `KeepAliveState` did not transition from `PingSent` to `Scheduled` after a pong was received. This prevented more than one ping to be sent by the server. This fix checks if `ping_sent_at` has already been cleared by `Ponger::poll` when `KeepAliveState::PingSent` state is active. Fixes #2310 --- src/proto/h2/ping.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/proto/h2/ping.rs b/src/proto/h2/ping.rs index c4fe2dd15c..54dd6442a8 100644 --- a/src/proto/h2/ping.rs +++ b/src/proto/h2/ping.rs @@ -442,7 +442,16 @@ impl KeepAlive { let interval = shared.last_read_at() + self.interval; self.timer.reset(interval); } - KeepAliveState::Scheduled | KeepAliveState::PingSent => (), + KeepAliveState::PingSent => { + if shared.is_ping_sent() { + return; + } + + self.state = KeepAliveState::Scheduled; + let interval = shared.last_read_at() + self.interval; + self.timer.reset(interval); + } + KeepAliveState::Scheduled => (), } }